home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software, Inc. 1997
- #
- # 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 1997 Cayenne Software, Inc.
-
-
- eval [$cc getCustomFileContents semanticbase tcl reports]
-
-
- Class ReportUseCases : {SemanticBase} {
- constructor
-
- attribute showUseCaseProperties
- attribute showDecompositions
- attribute prevReportedUseCase
-
- method doReport
-
- method printLine
- method printProperties
- }
-
-
- 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" 18
- $report print "UseCase/Actor" 21
- $report print "By Event" 26
- if [[$this fileV] isNil] {
- $report print "In FileVersion" 41
- }
- $report line
- $report 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"
- }
- if { "[[$event getConnector] type]" == "und_com_assoc" } {
- set nodeText "communicates with"
- }
-
- 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]
- set type [query -s getConnector.properties.value $inclusion]
- switch $type {
- "uses" { set text "is used by" }
- "extends" { set text "is extended by" }
- default { set text "is inherited by" }
- }
- $this printLine $useCaseName $text \
- $fromUseCaseName [$inclusion getDefiningDiagram]
- }
- foreach inclusion $outInclusions {
- set toUseCase [$inclusion getTo $OMT_UCD_UseCase]
- set toUseCaseName [$this objName $toUseCase]
- set type [query -s getConnector.properties.value $inclusion]
- switch $type {
- "" { set text "inherits from" }
- default { set text $type }
- }
- $this printLine $useCaseName $text \
- $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]
- if { "[$this prevReportedUseCase]" != "$useCase" } {
- $report print $useCase 20
- $this prevReportedUseCase $useCase
- } else {
- $report space 20
- }
- $report space
- $report print $does 17
- if ![lempty $with] {
- $report space
- $report print $with 20
- } elseif {"$does" != "is decomposed in"} {
- $report space 21
- }
- if ![lempty $event] {
- $report space
- $report print "$event" 25
- } elseif {"$does" != "is decomposed in"} {
- $report space 26
- }
- # don't print FileVersion if report is executed on file level
- if { [[$this fileV] isNil] || [lempty $with] } {
- $report space
- if ![lempty $in] {
- $report print [$this fullFileName $in] line
- } else {
- $report space line
- }
- } else {
- $report line
- }
- }
-
-
- method ReportUseCases::printProperties {this useCaseName useCaseWI} {
- if ![$this showUseCaseProperties] {
- return
- }
- if ![$useCaseWI isNil] {
- set properties [$useCaseWI properties]
- if [$properties isNil] {
- return
- }
-
- $this showProperties $properties
- }
- }
-
- # ----------------------------------------------------------------------
- #
- set executeMe [ReportUseCases new]
-