home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
reportbase.tcl
< prev
next >
Wrap
Text File
|
1997-08-27
|
9KB
|
319 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1995
#
# File: @(#)reportbase.tcl /main/titanic/5
# Author: Harm Leijendeckers
# Description: Base of all report classes
#
#---------------------------------------------------------------------------
# SccsId = @(#)reportbase.tcl /main/titanic/5 27 Aug 1997 Copyright 1995 Cadre Technologies Inc.
Class ReportBase : {GCObject} {
method destructor
constructor
method setHeader
method setFooter
method propertyHeader
method showProperties
method corporateReport
method projectReport
method configReport
method phaseReport
method systemReport
method fileReport
method levelError
method execute
method getLongName
method initProperties
attribute corporate
attribute project
attribute configV
attribute phaseV
attribute systemV
attribute fileV
attribute report
attribute reportName
attribute logo1
attribute logo2
attribute logo3
attribute logo4
attribute propDefs
}
constructor ReportBase {class this} {
set this [GCObject::constructor $class $this]
$this report [Report new]
$this reportName unknown
$this logo1 ""
$this logo2 "ObjectTeam"
$this logo3 [versionInfo majorVersion].[versionInfo minorVersion].[versionInfo maintVersion]
$this logo4 ""
set moduleHdlr [ModuleHandler new]
$moduleHdlr setCurrentContext
PropKnowledgeDB new .propDefsPath $moduleHdlr
$this propDefs .propDefsPath
return $this
}
method ReportBase::destructor {this} {
[$this report] delete
}
method ReportBase::initProperties {this} {
lappend ids [[$this corporate] identity]
if ![[$this project] isNil] { lappend ids [[$this project] identity] }
if ![[$this configV] isNil] { lappend ids [[$this configV] identity] }
if ![[$this phaseV ] isNil] { lappend ids [[$this phaseV ] identity] }
if ![[$this systemV] isNil] { lappend ids [[$this systemV] identity] }
if ![[$this fileV ] isNil] { lappend ids [[$this fileV ] identity] }
set pathIds [join [concat {""} $ids] /]
[$this propDefs] context $pathIds
}
method ReportBase::setHeader {this} {
# set a file-version header if on context level file
if ![[$this fileV] isNil] {
[$this report] header {
set report [$this report]
$report print - 131 fill line
$report print [$this logo1] 13 center break
$report print "| "
$report print "Report : [$this reportName]" 57
$report print "Date : [$report date]" line
$report print [$this logo2] 13 center break
$report print "| "
$report space 57
$report print "Creator :\
[[[$this corporate] currentUser] name]" line
$report print [$this logo3] 13 center break
$report print "| "
$report print "Project : [[$this project] name]" 57
$report print "System Version:\
[[[$this systemV] system] name].[[$this systemV] versionName]"
$report line
$report print [$this logo4] 13 center break
$report print "| "
$report print "Phase Version:\
[[[$this phaseV] phase] name].[[$this phaseV] versionName]" 57
$report print "File Version :\
[[[$this fileV] file] qualifiedName].[[[$this fileV] file] \
type].[[$this fileV] versionName]"
$report line
$report print - 131 fill line
$report line
}
return
}
# header for levels project, configuration, phase and system
[$this report] header {
set report [$this report]
$report print - 131 fill line
$report print [$this logo1] 13 center break
$report print "| "
$report print "Report : [$this reportName]" 57
$report print "Date : [$report date]" line
$report print [$this logo2] 13 center break
$report print "| "
$report space 57
$report print "Creator :\
[[[$this corporate] currentUser] name]" line
$report print [$this logo3] 13 center break
$report print "| "
if ![[$this project] isNil] {
$report print "Project :\
[[$this project] name]" 57
if ![[$this phaseV] isNil] {
$report print "Phase Version :\
[[[$this phaseV] phase] name].[[$this phaseV] versionName]"
}
}
$report line
$report print [$this logo4] 13 center break
$report print "| "
if ![[$this configV] isNil] {
$report print "Configuration Version:\
[[[$this configV] config] name].[[$this configV] versionName]" 57
if ![[$this systemV] isNil] {
$report print "System Version:\
[[[$this systemV] system] name].[[$this systemV] versionName]"
}
}
$report line
$report print - 131 fill line
$report line
}
}
method ReportBase::setFooter {this} {
[$this report] footer {
[$this report] line
[$this report] print "- [[$this report] pageno] -" 131 center line
}
}
method ReportBase::getLongName {this shortName} {
set propdef [[$this propDefs] definition $shortName]
if [lempty $propdef] {
return $shortName
}
return [$propdef longName]
}
method ReportBase::propertyHeader {this} {
[$this report] space 6
[$this report] print " - Property Name : Property Value" line
[$this report] print - [[$this report] linelen] fill line
[$this report] line
}
method ReportBase::showProperties {this object {selection {}} } {
if [lempty [$object properties]] {
return
}
set max 0
set newline 0
if [lempty $selection] {
foreach prop [$object properties] {
set len [string length [$this getLongName [$prop name]]]
if { $len > $max } { set max $len }
}
foreach prop [osort name [$object properties]] {
[$this report] space 6
[$this report] print "- "
[$this report] print "[$this getLongName [$prop name]]" $max
[$this report] print " : "
[$this report] print [$prop value] keepnl [expr 110 - $max] line
}
# Prints always one or more properties
set newline 1
} else {
foreach propName "$selection" {
set len [string length [$this getLongName $propName]]
if { $len > $max } { set max $len }
}
foreach propName "$selection" {
set value [$object getPropertyValue $propName]
if [lempty $value] continue
set newline 1
[$this report] space 6
[$this report] print "- "
[$this report] print "[$this getLongName $propName]" $max
[$this report] print " : "
[$this report] print "$value" keepnl [expr 110 - $max] line
}
}
if $newline { [$this report] line }
}
method ReportBase::corporateReport {this} {
foreach project [osort name [[$this corporate] projects]] {
$this project $project
if { [$this projectReport] == -1 } {
return -1
}
}
return 0
}
method ReportBase::projectReport {this} {
foreach configV [osort config.name versionNumber -versnum \
[[$this project] configVersions]] {
$this configV $configV
if { [$this configReport] == -1 } {
return -1
}
}
return 0
}
method ReportBase::configReport {this} {
foreach phaseV [[$this configV] phaseVersions] {
$this phaseV $phaseV
if { [$this phaseReport] == -1 } {
return -1
}
}
return 0
}
method ReportBase::phaseReport {this} {
foreach systemV [osort system.name versionNumber -versnum \
[query "system.type == system" [[$this phaseV] systemVersions]]] {
$this systemV $systemV
if { [$this systemReport] == -1 } {
return -1
}
}
return 0
}
method ReportBase::systemReport {this} {
foreach fileV [osort file.type file.name versionNumber -versnum \
[[$this systemV] localFileVersions]] {
$this fileV $fileV
if { [$this fileReport] == -1 } {
return -1
}
}
return 0
}
method ReportBase::fileReport {this} {
$this levelError
return -1
}
method ReportBase::levelError {this} {
[$this report] print "This report cannot be executed on context "
[$this report] print "level [[ClientContext::global] currentLevel]"
[$this report] line
}
method ReportBase::execute {this} {
set cc [ClientContext::global]
$this corporate [$cc currentCorporate]
$this project [$cc currentProject]
$this configV [$cc currentConfig]
$this phaseV [$cc currentPhase]
$this systemV [$cc currentSystem]
$this fileV [$cc currentFile]
$this initProperties
$this setHeader
$this setFooter
case [$cc currentLevel] in {
Corporate { $this corporateReport }
Project { $this projectReport }
Config { $this configReport }
Phase { $this phaseReport }
System { $this systemReport }
File { $this fileReport }
default { $this levelError }
}
}