home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)psysvdbobj.tcl /main/hindenburg/13
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)psysvdbobj.tcl /main/hindenburg/13 28 Nov 1996 Copyright 1996 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 selectDatabase
- method setPassword
- method updateUserEnv
- attribute hostIfName
- attribute databaseIfName
- }
-
- 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
- unpack_package
- $this hostIfName "Server"
- $this databaseIfName "Database"
- global target
- if {$target == "ORACLE"} {
- $this hostIfName "Oracle SID"
- $this databaseIfName "Schema"
- }
- }
-
- 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 groupVersions customFileVersionSet \
- savedGroupVersionSet workItemSet controlledListSet accessRuleSet\
- }
- }
-
- 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
- [.main menuHdlr] selectionChanged
- 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
- [.main menuHdlr] selectionChanged
-
- 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
- [.main menuHdlr] selectionChanged
- }
-
- 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
- } 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 ""
- }
-
- $this SysVDbObj::importObject $context $node
-
- if {"$levelIds" != ""} {
- $clientContext setLevelIds $levelIds
- }
- }
-
- proc PSysVDbObj::infoProperties {} {
- return [SysVDbObj::infoProperties]
- }
-
- method PSysVDbObj::needPassword {this {context ""}} {
- global 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} {
- 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]
- set options \
- "$overw -x -F $argsFile -S $systemName -A $prevPhase -T ObjectDesign"
-
- set script "[quoteIf [m4_path_name bin reveng_${lang}$EXE_EXT]] $options"
- .main startCommand xtool \
- "$script" "" \
- "Starting 'Round trip selected files'..." \
- {1 0} 0
- }
-
- 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]
-
- .main busy 1
- if {$target == "SYBASE" || $target == "SQLSERVER"} {
- if [[.main.selectDatabase pSys] needPassword $host] {
- set pSys [.main.selectDatabase pSys]
- 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]
- }
- .main busy 0
- }
- $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
- [.main menuHdlr] selectionChanged
- wmtkmessage \
- "[$pSys databaseIfName] '$name' on '$host' selected"
- global target
- 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
-
-