home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1997
- #
- # File: @(#)msumlassoc.tcl /main/titanic/2
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)msumlassoc.tcl /main/titanic/2 29 Aug 1997 Copyright 1997 Cayenne Software Inc.
-
- # Start user added include file section
- # End user added include file section
-
- #require "msumleleme.tcl"
-
- Class MSUMLAssociation : {MSUMLElement} {
- constructor
- method destructor
- method ot2ms
- method ms2ot
- method promoter
- method roleSet
- method addRole
- method removeRole
- attribute smAssociation
- attribute _roleSet
- }
-
- constructor MSUMLAssociation {class this typeName smAssociation} {
- set this [MSUMLElement::constructor $class $this $typeName]
- $this smAssociation $smAssociation
- $this _roleSet [List new]
- # Start constructor user section
- # End constructor user section
- return $this
- }
-
- method MSUMLAssociation::destructor {this} {
- foreach ref [[$this _roleSet] contents] {
- $ref _association ""
- }
- # Start destructor user section
- [$this roleSet] foreach role {
- $role delete
- }
- # End destructor user section
- $this MSUMLElement::destructor
- }
-
- method MSUMLAssociation::ot2ms {this package} {
- set smConnector [$this smAssociation]
- set item [$smConnector getItem]
- set name ""
- if ![$item isNil] {
- set name [$item name]
- } else {
- set name noName
- }
- global trans
- $trans begin
- puts "\tAssociation '$name'"
- set umlAssoc [$package createAssociation $name]
- set workItem [$smConnector getWorkItem]
- if ![$workItem isNil] {
- $this saveFreeTextProp $umlAssoc [$workItem properties]
- }
- $this msUmlObject $umlAssoc
- $trans commit
- return $umlAssoc
-
- }
-
- method MSUMLAssociation::ms2ot {this rtDiag} {
- set roleSet [$this roleSet]
- set assocName [$this name]
- puts "\tAssociation '$assocName'"
- set noOfClasses [$roleSet length]
- if {$noOfClasses < 2} {
- puts "association $assocName with less than 2 classes"
- exit
- }
- set role1 [$roleSet index 0]
- set class1 [$role1 getTypeAsUML]
- MSUMLClass promote $class1
- set cl1Name [[$class1 property msObject] property name]
-
- set role2 [$roleSet index 1]
- set class2 [$role2 getTypeAsUML]
- MSUMLClass promote $class2
- set cl2Name [[$class2 property msObject ] property name]
-
- set c1 [$class1 ms2ot $rtDiag "find"]
- set c2 [$class2 ms2ot $rtDiag "find"]
- set iRole1 [$role1 getInterface IUmlAssociationRole]
- set iRole2 [$role2 getInterface IUmlAssociationRole]
- set isAggr1 [$iRole1 property IsAggregate]
- set isAggr2 [$iRole2 property IsAggregate]
- if {[llength $isAggr1] && $isAggr1 == "1"} {
- set assoc [$rtDiag addConn "aggregation" $c1 $c2]
- } elseif {[llength $isAggr2] && $isAggr2 == "1"} {
- set assoc [$rtDiag addConn "aggregation" $c2 $c1]
- } else {
- set assoc [$rtDiag addConn "association" $c1 $c2]
- }
- $this loadFreeTextProp $assoc
- $this loadFreeTextProp $assoc role_start
- $this loadFreeTextProp $assoc role_end
- $role1 ms2ot $assoc "start"
- $role2 ms2ot $assoc "end"
- $iRole1 delete
- $iRole2 delete
- return $assoc
- }
-
- method MSUMLAssociation::promoter {this} {
- $this MSUMLElement::promoter
- #classes
- $this _roleSet [List new]
- # Roles
- set noOfRoles [$this getNoOfRoles]
- for {set i 1} {$i <= $noOfRoles} {incr i} {
- set umlRole [$this getRoleAsUML $i]
- MSUMLAssRole promote $umlRole $this
- }
- }
-
- # Do not delete this line -- regeneration end marker
-
- method MSUMLAssociation::roleSet {this} {
- return [$this _roleSet]
- }
-
- method MSUMLAssociation::addRole {this newRole} {
- [$this _roleSet] append $newRole
- $newRole _association $this
- }
-
- method MSUMLAssociation::removeRole {this oldRole} {
- $oldRole _association ""
- [$this _roleSet] removeValue $oldRole
- }
-
-