home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
usecases.tcl
< prev
next >
Wrap
Text File
|
1997-04-29
|
7KB
|
253 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software, Inc. 1996
#
# File: %W%
# Author: Harm Leijendeckers
# Description: Report on UseCases
# Usage in: SystemVersion and UCD editor
# Options: properties : show basic, alternative courses of
# action, pre- and postconditions and
# freeText of each UseCase
# decompositions: show decomposition information
#
#---------------------------------------------------------------------------
# SccsId = %W% %G% Copyright 1996 Cayenne Software, Inc.
eval [$cc getCustomFileContents semanticbase tcl reports]
Class ReportUseCases : {SemanticBase} {
constructor
attribute showUseCaseProperties
attribute showDecompositions
method doReport
method printLine
method printProperties
method printProperty
}
constructor ReportUseCases {class this} {
set this [SemanticBase::constructor $class $this]
$this reportName "UseCases"
if { [lsearch $Options "properties"] != -1 } {
$this showUseCaseProperties 1
} else {
$this showUseCaseProperties 0
}
if { [lsearch $Options "decompositions"] != -1 } {
$this showDecompositions 1
} else {
$this showDecompositions 0
}
return $this
}
method ReportUseCases::doReport {this model} {
# get all UseCases
set useCases [concat [$model getSMObjects $OMT_UCD_UseCase]]
if [lempty $useCases] { return 0 }
set report [$this report]
$report header {
set report [$this report]
$report print "UseCase" 21
$report print "Action" 17
$report print "UseCase/ETD" 21
if [[$this fileV] isNil] {
$report print "In FileVersion" 41
}
$report print "By Event" line
$report line
}
# retrieve all etd's and put them in a QueryObject for later use
if [$this showDecompositions] {
set allEtds [query "file.type == etd" \
$this.phaseV.systemVersions.localFileVersions]
set qoAllEtds [QueryObject new allEtds file.item]
}
# sort on UseCase name
set useCasessWithoutName [query "getLabel.isNil == 1" $useCases]
set useCasessWithName [query "getLabel.isNil == 0" $useCases]
set sortedUseCases [concat $useCasessWithoutName \
[osort getLabel.value $useCasessWithName]]
foreach useCase $sortedUseCases {
set useCaseName [$this objName $useCase]
# all incomming and outgoing events
set events [concat \
[$useCase getConnectorsIn \
$OMT_UCD_UndirectedCommunicationAssociation $OMT_UCD_Actor] \
[$useCase getConnectorsIn \
$OMT_UCD_DirectedCommunicationAssociation $OMT_UCD_Actor] \
[$useCase getConnectorsOut \
$OMT_UCD_UndirectedCommunicationAssociation $OMT_UCD_Actor] \
[$useCase getConnectorsOut \
$OMT_UCD_DirectedCommunicationAssociation $OMT_UCD_Actor]]
foreach event $events {
set actor [$event getFrom $OMT_UCD_Actor]
set type "incomming"
if [lempty $actor] {
set actor [$event getTo $OMT_UCD_Actor]
set type "outgoing"
}
set actorName [$this objName $actor]
if { $type == "incomming" } {
set actorNode [$actor getComponents]
if { [$actorNode getPropertyValue initiator] == "1" } {
set nodeText "is initiated by"
} else {
set nodeText "receives from"
}
} else {
set nodeText "sends to"
}
set eventName [$this objName $event]
$this printLine $useCaseName $nodeText $actorName \
[$event getDefiningDiagram] $eventName
}
# get the UseCases this UseCase is included in
set inInclusions [concat [$useCase getConnectorsIn \
$OMT_UCD_UseCaseGeneralization $OMT_UCD_UseCase]]
set outInclusions [concat [$useCase getConnectorsOut \
$OMT_UCD_UseCaseGeneralization $OMT_UCD_UseCase]]
foreach inclusion $inInclusions {
set fromUseCase [$inclusion getFrom $OMT_UCD_UseCase]
set fromUseCaseName [$this objName $fromUseCase]
$this printLine $useCaseName "is included by" \
$fromUseCaseName [$inclusion getDefiningDiagram]
}
foreach inclusion $outInclusions {
set toUseCase [$inclusion getTo $OMT_UCD_UseCase]
set toUseCaseName [$this objName $toUseCase]
$this printLine $useCaseName "includes" \
$toUseCaseName [$inclusion getDefiningDiagram]
}
# get decomposition of current UseCase (this is optionally)
if [$this showDecompositions] {
set useCaseItem [$useCase getItem]
set useCaseWorkItem [$useCase getWorkItem]
if ![$useCaseItem isNil] {
[$this phaseV] getDecompositions $useCaseItem [$this configV] \
decompFiles {ucd etd} dummy fileVersions
# add decomposed etd's to fileVersions
if ![$useCaseWorkItem isNil] {
foreach wi [$useCaseWorkItem qualifiedDeclarations] {
set etd [query "file.item == [$wi item]" $qoAllEtds]
if ![lempty $etd] {
lappend fileVersions $etd
}
}
}
foreach fileVersion [osort file.type -decr file.qualifiedName \
$fileVersions] {
$this printLine $useCaseName "is decomposed in" "" \
$fileVersion
}
}
}
# print special UseCase properties of current UseCase
$this printProperties $useCaseName [$useCase getWorkItem]
$report line
}
$report page
$report remove header
return 0
}
method ReportUseCases::printLine {this useCase does with in {event ""}} {
set report [$this report]
$report print $useCase 20
$report space
$report print $does 16
if ![lempty $with] {
$report space
$report print $with 20
}
# don't print FileVersion if report is executed on file level
if { [[$this fileV] isNil] || [lempty $with] } {
if { $does == "is decomposed in" || [lempty $event] } {
set len "80"
} else {
set len 40
}
$report space
if ![lempty $in] {
$report print [$this fullFileName $in] $len
} else {
$report space $len
}
}
if ![lempty $event] {
$report space
$report print "$event" 31
}
$report line
}
method ReportUseCases::printProperties {this useCaseName useCaseWI} {
if ![$this showUseCaseProperties] {
return
}
if ![$useCaseWI isNil] {
set properties [$useCaseWI properties]
if [$properties isNil] {
return
}
foreach propDes {{basicAct "Basic Course of Action"}
{alternateAct "Alternative Course of Action"}
{precond "Precondition"}
{postcond "Postcondition"}
{freeText "Free Text"}} {
set propName [lvarpop propDes]
set propText [lvarpop propDes]
$this printProperty $useCaseName $properties $propName $propText
}
}
}
method ReportUseCases::printProperty {this useCaseName properties propName \
header} {
set report [$this report]
set propVal [$properties getPropertyValue $propName]
if ![lempty $propVal] {
$report line
$report print "$header for $useCaseName:" line
$report space 4
$report print $propVal 120 line
}
}
# ----------------------------------------------------------------------
#
set executeMe [ReportUseCases new]