home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software, Inc. 1996
- #
- # File: %W%
- # Author: Harm Leijendeckers
- # Description: Report on UseCase actors
- # Usage in: SystemVersion and UCD editor
- # Options: freeText: show freeText of each actor
- # properties: show all properties of each actor
- #
- #---------------------------------------------------------------------------
- # SccsId = %W% %G% Copyright 1996 Cayenne Software, Inc.
-
-
- eval [$cc getCustomFileContents semanticbase tcl reports]
-
-
- Class ReportActors : {SemanticBase} {
- constructor
-
- method doReport
- method getEvents
- method findCommunication
-
- method printFreeText
- attribute showFreeText
- attribute showPropVals
- }
-
-
- constructor ReportActors {class this} {
- set this [SemanticBase::constructor $class $this]
- $this reportName "UseCase Actors"
- $this showFreeText 0
- $this showPropVals 0
- if { [lsearch $Options "freeText"] != -1 } { $this showFreeText 1 }
- if { [lsearch $Options "properties"] != -1 } { $this showPropVals 1 }
- return $this
- }
-
-
- method ReportActors::getEvents {this Actor} {
- set events ""
- switch [[$Actor getSemType] getCompType] {
- ucd_actor {
- set events [concat \
- [$Actor getConnectorsIn \
- $OMT_UCD_UndirectedCommunicationAssociation \
- $OMT_UCD_UseCase] \
- [$Actor getConnectorsOut \
- $OMT_UCD_UndirectedCommunicationAssociation \
- $OMT_UCD_UseCase] \
- [$Actor getConnectorsIn \
- $OMT_UCD_DirectedCommunicationAssociation \
- $OMT_UCD_UseCase] \
- [$Actor getConnectorsOut \
- $OMT_UCD_DirectedCommunicationAssociation \
- $OMT_UCD_UseCase] \
- ]
- }
- cod_actor {
- set events [concat \
- [$Actor getConnectorsIn \
- $OMT_COD_Link $OMT_COD_Instance] \
- [$Actor getConnectorsOut \
- $OMT_COD_Link $OMT_COD_Instance] \
- ]
- }
- etd_initiator {
- set events [concat \
- [$Actor getConnectorsIn \
- $OMT_ETD_Event $OMT_ETD_Initiator] \
- [$Actor getConnectorsOut \
- $OMT_ETD_Event $OMT_ETD_Initiator] \
- [$Actor getConnectorsIn \
- $OMT_ETD_Event $OMT_ETD_Object] \
- [$Actor getConnectorsOut \
- $OMT_ETD_Event $OMT_ETD_Object] \
- ]
- }
- default {
- }
- }
- return $events
- }
-
-
- method ReportActors::findCommunication {this Event from} {
- set node ""
- set text ""
-
- set fromNode [$from getComponents]
- if { [$fromNode getPropertyValue initiator] == "1" } {
- set text "initiates"
- } else {
- set text "sends to"
- }
-
- switch [[$Event getConnector] type] {
- link {
- # COD
- set text "is linked with"
- set node [$Event getTo $OMT_COD_Instance]
- if { [lempty $node] || $node == $from } {
- set node [$Event getFrom $OMT_COD_Instance]
- }
- }
- und_com_assoc {
- # UCD
- set text "communicates with"
- set node [$Event getTo $OMT_UCD_UseCase]
- if { [lempty $node] || $node == $from } {
- set node [$Event getFrom $OMT_UCD_UseCase]
- }
- }
- dir_com_assoc {
- # UCD
- set node [$Event getTo $OMT_UCD_UseCase]
- if { [lempty $node] || $node == $from } {
- set text "receives from"
- set node [$Event getFrom $OMT_UCD_UseCase]
- }
- }
- etd_event {
- # ETD
- set text "sends to"
- set node [$Event getTo $OMT_ETD_Initiator]
- if { [lempty $node] || $node == $from } {
- set node [$Event getTo $OMT_ETD_Object]
- }
- if { [lempty $node] || $node == $from } {
- set text "receives from"
- set node [$Event getFrom $OMT_ETD_Initiator]
- }
- if { [lempty $node] || $node == $from } {
- set node [$Event getFrom $OMT_ETD_Object]
- }
- }
- }
- return [list $text $node]
- }
-
- method ReportActors::doReport {this model} {
- # get all UCD actors
- set actors [concat [$model getSMObjects $OMT_UCD_Actor] \
- [$model getSMObjects $OMT_COD_Actor] \
- [$model getSMObjects $OMT_ETD_Initiator]]
- if [lempty $actors] { return 0 }
-
- set report [$this report]
- $report header {
- set report [$this report]
- $report print "Actor" 21
- $report print "Action" 18
- $report print "UseCase/Object" 21
- if [[$this fileV] isNil] {
- $report print "By Event" 31
- $report print "In FileVersion" line
- } else {
- $report print "By Event" line
- }
- $report line
- }
-
- # Sort on actor name
- # First get all actors without a name
- set actorsWithoutName [query "getLabel.isNil == 1" $actors]
- set actorsWithName [query "getLabel.isNil == 0" $actors]
- set sortedActors [concat $actorsWithoutName \
- [osort getLabel.value $actorsWithName]]
-
- set prevActorName ""
- set prevActorI [ORB::nil]
- set prevDiagram [ORB::nil]
-
- foreach actor $sortedActors {
- set events [$this getEvents $actor]
-
- set actorName [$this objName $actor]
-
- # print freeText of previous actor
- if { $prevActorName != $actorName } {
- $this printFreeText $prevActorName $prevActorI $prevDiagram
- }
-
- # $report [query -s getSemType.getCompType $actor]
-
- if [lempty $events] {
- $report print $actorName 20
- $report space
- $report print "** no actions **" 17
- $report space 53
- if [[$this fileV] isNil] {
- set fv [$actor getDefiningDiagram]
- $report print [$this fullFileName $fv] 40
- }
- $report line
- }
-
- set actorPrinted 0
- foreach event $events {
- set communication [$this findCommunication $event $actor]
- set toNode [lindex $communication 1]
- set eventName [$this objName $event]
-
- if { ! $actorPrinted } {
- $report print $actorName 20
- set actorPrinted 1
- } else {
- $report space 20
- }
- $report space
- $report print [lindex $communication 0] 17
- $report space
- $report print [$this objName $toNode] 20
- $report space
-
- # don't print fileVersion if executed on file level, so the
- # available space for the event text depends on it
- if [[$this fileV] isNil] {
- $report print $eventName 30
- $report space
- set fv [$event getDefiningDiagram]
- $report print [$this fullFileName $fv] 40
- } else {
- $report print $eventName 71
- }
- $report line
- }
-
- set prevActorName $actorName
- set prevActorI [$actor getItem]
- set prevDiagram [$actor getDefiningDiagram]
- }
-
- # print freeText of precious actor
- $this printFreeText $prevActorName $prevActorI $prevDiagram
-
- $report page
- $report remove header
-
- return 0
- }
-
-
- method ReportActors::printFreeText {this actorName actorI diagram} {
- if { [$actorI isNil] || [$diagram isNil] } {
- [$this report] line
- return
- }
- if { ![$this showFreeText] && ![$this showPropVals] } {
- [$this report] line
- return
- }
-
- set actorWI [$diagram findDeclaration $actorI [$this configV]]
-
- if ![$actorWI isNil] {
- set report [$this report]
- set properties [$actorWI properties]
- if ![$properties isNil] {
- if { [$this showPropVals] } {
- $this showProperties $properties
- } else {
- $this showProperties $properties freeText
- }
- }
- }
- [$this report] line
- return
- }
-
-
- # ----------------------------------------------------------------------
- #
- set executeMe [ReportActors new]
-