home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
psysvdbobj.tcl
< prev
next >
Wrap
Text File
|
1997-11-12
|
16KB
|
580 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)psysvdbobj.tcl /main/titanic/23
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)psysvdbobj.tcl /main/titanic/23 12 Nov 1997 Copyright 1997 Cayenne Software Inc.
# Start user added include file section
require "wmt_util.tcl"
# End user added include file section
require "ssysvdbobj.tcl"
Class PSysVDbObj : {SSysVDbObj} {
constructor
method destructor
method promoter
method addFileVersion
method allowsDrop
method createDatabase
method deselectDatabase
method destroyDatabase
method doCreateDatabase
method doDestroyDatabase
method filterType
method importFromPrevPhase
method importObject
method needPassword
method roundtripEngineer
method roundtripOk
method selectDatabase
method setPassword
method updateUserEnv
attribute hostIfName
attribute databaseIfName
attribute target
}
constructor PSysVDbObj {class this name} {
set this [SSysVDbObj::constructor $class $this $name]
$this hostIfName "Server"
$this databaseIfName "Database"
# Start constructor user section
# End constructor user section
return $this
}
method PSysVDbObj::destructor {this} {
# Start destructor user section
# End destructor user section
$this SSysVDbObj::destructor
}
method PSysVDbObj::promoter {this} {
$this SSysVDbObj::promoter
$this hostIfName "Server"
$this databaseIfName "Database"
# this sets the target attribute to the appropriate value
if [catch {uplevel source [list [m4_path_name tcl tgtname.tcl]]}] {
resetErrorVars
}
if {[$this target] == "ORACLE"} {
$this hostIfName "Oracle SID"
$this databaseIfName "Schema"
}
module_promoter PSysVDbObj $this
}
method PSysVDbObj::addFileVersion {this} {
require "newextfvdi.tcl"
# show a box to choose name en type
set box .main.newExternalFV
if {! [isCommand $box]} {
NewExtFVDialog new $box
}
$box popUp
}
method PSysVDbObj::allowsDrop {this uiClass} {
case "$uiClass" in {
{CorporateGroupVersion ExternalFileVersion GroupVersion} {
return 1
}
{default} {
return 0
}
}
}
proc PSysVDbObj::associations {} {
return {localFileVersions externalLinks customFileVersionSet workItemSet}
}
proc PSysVDbObj::childTypes {assoc} {
if {[lsearch -exact "[PSysVDbObj::associations]" "$assoc"] == -1} {
return ""
}
set childTypes [BrowserProcs::childTypes $assoc]
case "$childTypes" in {
{LocalFileVersion} {
return "${BrowserProcs::programmerFileTypes}"
}
{default} {
return [SysVDbObj::childTypes "$assoc"]
}
}
}
proc PSysVDbObj::controlledLists {} {
return [SSysVDbObj::controlledLists]
}
method PSysVDbObj::createDatabase {this} {
set box .main.createDatabase
if {! [isCommand $box]} {
ClassMaker::extend TemplateDialog CreateDatabaseDialog pSys
interface CreateDatabaseDialog $box {
modal yes
DlgColumn DC {
Label hostL {
text "Host:"
}
SingleLineText hostSLT {}
Label databaseL {
text "Database Name:"
}
SingleLineText dbNameSLT {}
}
}
$box title "Create [$this databaseIfName]"
$box.DC.hostL text [$this hostIfName]
$box.DC.databaseL text [$this databaseIfName]
$box config \
-pSys $this \
-helpPressed {.main helpOnName createDatabase} \
-okPressed {
set host [%this.DC.hostSLT text]
set name "[%this.DC.dbNameSLT text]"
set pSys [%this pSys]
if {$host == ""} {
wmtkerror "Invalid [$pSys hostIfName] specified"
} elseif {$name == ""} {
wmtkerror "Invalid [$pSys databaseIfName] specified"
} else {
set curConfig [[ClientContext::global] currentConfig]
$curConfig setProperty tdbname $name
$curConfig setProperty tdbhost $host
# update the menu enabling
global makeSelectionUpToDate
set makeSelectionUpToDate 0
[.main menuHdlr] selectionChanged
set makeSelectionUpToDate 1
if [$pSys needPassword] {
$pSys setPassword "$pSys doCreateDatabase $host $name"
} else {
$pSys doCreateDatabase $host $name
}
}
}
}
$box popUp
}
method PSysVDbObj::deselectDatabase {this} {
set curConfig [[ClientContext::global] currentConfig]
set name [$curConfig getPropertyValue tdbname]
set host [$curConfig getPropertyValue tdbhost]
$curConfig setProperty tdbname ""
$curConfig setProperty tdbhost ""
# update the menu enabling
global makeSelectionUpToDate
set makeSelectionUpToDate 0
[.main menuHdlr] selectionChanged
set makeSelectionUpToDate 1
wmtkmessage "[$this databaseIfName] '$name' on '$host' deselected"
}
method PSysVDbObj::destroyDatabase {this} {
set curConfig [[ClientContext::global] currentConfig]
set name [$curConfig getPropertyValue tdbname]
set host [$curConfig getPropertyValue tdbhost]
if [$this needPassword] {
$this setPassword "$this doDestroyDatabase \"$host\" \"$name\""
} else {
$this doDestroyDatabase $host $name
}
$curConfig setProperty tdbname ""
$curConfig setProperty tdbhost ""
# update the menu enabling
global makeSelectionUpToDate
set makeSelectionUpToDate 0
[.main menuHdlr] selectionChanged
set makeSelectionUpToDate 1
}
method PSysVDbObj::doCreateDatabase {this host database} {
set otsh [quoteIf [m4_path_name bin otsh$EXE_EXT]]
set script "$otsh -f tdbop.tcl -- createDatabase $name $host"
set message \
"Creating [$this databaseIfName] '$name'\
on [$this hostIfName] '$host'..."
.main startCommand mtool "$script" "" "$message" {0 0} 1
}
method PSysVDbObj::doDestroyDatabase {this host database} {
set otsh [quoteIf [m4_path_name bin otsh$EXE_EXT]]
set script "$otsh -f tdbop.tcl -- dropDatabase $database $host"
set message "Destroying [$this databaseIfName] '$database' on '$host'..."
.main startCommand mtool "$script" "" "$message" {0 0} 1
}
method PSysVDbObj::filterType {this} {
return Programmer
}
method PSysVDbObj::importFromPrevPhase {this mode} {
if {"$mode" == "selected"} {
set tmpFile [args_file {}]
set fid [open $tmpFile w]
foreach obj [.main selectedObjSet] {
if [$obj isA SystemFileReference] {
set confV [$obj getParent ConfigVersion]
set fileV [$obj referredFileVersion]
if [$fileV isA ExternalFileVersion] {
puts $fid "[$fileV identity]"
}
} elseif [$obj isA ExternalFileVersion] {
puts $fid "[$obj identity]"
}
}
close $fid
set options "-S oopl -t $tmpFile -f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
} elseif {"$mode" == "new-oopl"} {
set options "-S oopl -f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
} elseif {"$mode" == "new-sql"} {
set options "-S sql -f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
} else {
set box .main.importNew
if {! [isCommand $box]} {
interface TemplateDialog $box {
title "Import New"
modal yes
DlgColumn DC {
Label L {
text "Import new"
alignment CENTER
}
CheckButton SQLCB {
label SQL
}
CheckButton OOPLCB {
label OOPL
}
}
}
$box config \
-helpPressed {.main helpOnName importNew} \
-okPressed {
if [%this.DC.SQLCB state] {
set options "-S sql "
} else {
set options ""
}
if [%this.DC.OOPLCB state] {
append options "-S oopl "
}
append options "-f import.tcl"
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] $options"
.main startCommand mtool \
"$script" "" \
"Starting 'Import From Previous Phase'..." \
{1 0} 0
}
}
$box popUp
}
}
method PSysVDbObj::importObject {this context node} {
# The ClientContext must be set to the source
# system in order to determine the file's path
set clientContext [ClientContext::global]
set currentSysV [$clientContext currentSystem]
if {([llength $context] >= 6) && ([$currentSysV isNil] ||
[$currentSysV getInfo Identity] != [lindex $context 3])} {
set levelIds [$clientContext currentLevelIdString]
while {! [[$clientContext currentProject] isNil]} {
$clientContext upLevel
}
$clientContext downLevelId \
[BrowserProcs::id2obj [lindex $context 0] Project $node]
$clientContext downLevelId \
[BrowserProcs::id2obj [lindex $context 1] ConfigVersion $node]
$clientContext downLevelId \
[BrowserProcs::id2obj [lindex $context 2] PhaseVersion $node]
$clientContext downLevelId \
[BrowserProcs::id2obj [lindex $context 3] SystemVersion $node]
} else {
set levelIds ""
}
set result [$this SysVDbObj::importObject $context $node]
if {"$levelIds" != ""} {
$clientContext setLevelIds $levelIds
}
return $result
}
proc PSysVDbObj::infoProperties {} {
return [SysVDbObj::infoProperties]
}
method PSysVDbObj::needPassword {this {context ""}} {
set target [$this target]
if {$target != "ORACLE" && $target != "SYBASE" && $target != "SQLSERVER"} {
return 0
}
set curConfig [[ClientContext::global] currentConfig]
if {$target == "ORACLE"} {
if {$context == ""} {
set database [$curConfig getPropertyValue tdbname]
} else {
set database $context
}
set passWord [m4_var get M4_password -context $database]
} else {
if {$context == ""} {
set host [$curConfig getPropertyValue tdbhost]
} else {
set host $context
}
set passWord [m4_var get M4_password -context $host]
}
if {$passWord == ""} {
return 1
}
return 0
}
method PSysVDbObj::roundtripEngineer {this lang} {
switch $lang {
"vb" -
"pb" -
"delphi" {
set box $wmttoolObj.rountrip$lang
if {! [isCommand $box]} {
EntryDialog new $box \
-title "Roundtrip" \
-message "Diagram Prefix"
$box config \
-okPressed "$this roundtripOk $lang \[$box entry\]"
$box delHelpButton
}
$box popUp
}
default {
$this roundtripOk $lang ""
}
}
}
method PSysVDbObj::roundtripOk {this lang fileName} {
uplevel #0 {require "config.tcl"}
set clientContext [ClientContext::global]
set config [args_file {}]
$clientContext downLoadCustomFile roundtrip roundtrip etc $config
set configList [readConfigurationFile $config]
unlink $config
set overwriteDiagram "no"
foreach configLine $configList {
if {[lindex $configLine 0] == "diagram"} {
if {[lindex $configLine 1] == "overwrite"} {
set overwriteDiagram [lindex $configLine 3]
break
}
}
}
set systemName [[[$clientContext currentSystem] system] name]
set pathList ""
foreach obj [.main selectedObjSet] {
lappend pathList [$obj path]
}
set argsFile [args_file $pathList]
if {$overwriteDiagram == "yes"} {
set overw "-o"
} else {
set overw ""
}
set prevPhase [[[[$clientContext currentPhase] previous \
[$clientContext currentConfig]] phase] name]
if {$fileName != ""} {
set options "$overw -x -F $argsFile -D $fileName -S $systemName -A $prevPhase -T ObjectDesign"
} else {
set options "$overw -x -F $argsFile -S $systemName -A $prevPhase -T ObjectDesign"
}
if {[$clientContext customFileExists ${lang}roundtrip tcl tcl 1]} {
set script "[quoteIf [m4_path_name bin otsh$EXE_EXT]] -f ${lang}roundtrip.tcl -- $options"
} else {
set script "[quoteIf [m4_path_name bin reveng_${lang}$EXE_EXT]] $options"
}
set box $wmttoolObj.roundtripEngineer
if ![isCommand $box] {
require roundtripd.tcl
RoundtripDlg new $box
}
$box command $script
$box popUp
}
method PSysVDbObj::selectDatabase {this} {
set box .main.selectDatabase
if {! [isCommand $box]} {
require "listdbs.tcl"
ClassMaker::extend TemplateDialog SelectDatabaseDialog pSys
interface SelectDatabaseDialog $box {
title "Select Database"
modal yes
DlgColumn DC {
DlgRow DR {
DlgColumn DC {
Label hostL {
text "Host:"
}
SingleLineText hostSLT {}
}
PushButton applyPB {
label "Apply"
}
}
Label databaseL {
text "Database:"
}
ComboBox databasesCB {
rowCount 5
}
}
}
$box.DC.DR.DC.hostL text [$this hostIfName]
$box.DC.databaseL text [$this databaseIfName]
$box.DC.DR.applyPB activated {
set host [.main.selectDatabase.DC.DR.DC.hostSLT text]
set name [.main.selectDatabase.DC.databasesCB text]
busy {
set pSys [.main.selectDatabase pSys]
if {[$pSys target] == "SYBASE" || [$pSys target] == "SQLSERVER"} {
if [[.main.selectDatabase pSys] needPassword $host] {
if {$name == ""} {
wmtkerror "Invalid [$pSys databaseIfName] specified"
} elseif { $host == ""} {
wmtkerror "Invalid [$pSys hostIfName] specified"
}
[.main.selectDatabase pSys] setPassword \
".main.selectDatabase.DC.databasesCB entrySet \
\[listDatabases $host\]" "$host" "$database"
} else {
.main.selectDatabase.DC.databasesCB entrySet \
[listDatabases $host]
}
} else {
.main.selectDatabase.DC.databasesCB entrySet \
[listDatabases $host]
}
}
}
$box config \
-pSys $this \
-helpPressed {.main helpOnName selectDatabase} \
-okPressed {
set host [string trim [%this.DC.DR.DC.hostSLT text]]
set name [string trim [%this.DC.databasesCB text]]
set pSys [%this pSys]
if {$name == ""} {
wmtkerror "Invalid [$pSys databaseIfName] specified"
} elseif { $host == ""} {
wmtkerror "Invalid [$pSys hostIfName] specified"
} else {
set curConfig [[ClientContext::global] currentConfig]
$curConfig setProperty tdbname $name
$curConfig setProperty tdbhost $host
# update the menu enabling
global makeSelectionUpToDate
set makeSelectionUpToDate 0
[.main menuHdlr] selectionChanged
set makeSelectionUpToDate 1
wmtkmessage \
"[$pSys databaseIfName] '$name' on '$host' selected"
if [$pSys needPassword] {
$pSys setPassword
}
}
}
}
set curConfig [[ClientContext::global] currentConfig]
$box.DC.databasesCB text [$curConfig getPropertyValue tdbname]
if {[$box.DC.DR.DC.hostSLT text] != [$curConfig getPropertyValue tdbhost]} {
.main.selectDatabase.DC.databasesCB entrySet {}
}
$box.DC.DR.DC.hostSLT text [$curConfig getPropertyValue tdbhost]
$box popUp
}
method PSysVDbObj::setPassword {this {script ""} {tdbHost ""} {tdbName ""}} {
require "dbasepwddi.tcl"
DbasePwdDialog new .main.dbasePwdDialog
.main.dbasePwdDialog popUp "$script" "$tdbHost" "$tdbName"
}
method PSysVDbObj::updateUserEnv {this} {
busy {
foreach obj [[[.main infoView] area] objectSet] {
set browsUiObj [$obj browsUiObj]
if {! [$browsUiObj isA ExternalFileVersion]} continue
set path [$browsUiObj path]
if {"[$browsUiObj getInfo Status]" != "working"} {
catch {BasicFS::removeFile $path}
}
if {! [file exists $path]} {
$browsUiObj synchWithFileSystem
}
}
}
}
# Do not delete this line -- regeneration end marker