home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
msumlassro.tcl
< prev
next >
Wrap
Text File
|
1997-08-29
|
5KB
|
188 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1997
#
# File: @(#)msumlassro.tcl /main/titanic/2
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)msumlassro.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 "msumltypee.tcl"
Class MSUMLAssRole : {MSUMLTypeExpression} {
constructor
method destructor
method ms2ot
method ot2ms
method promoter
method association
method owner
attribute side
attribute _association
attribute _owner
attribute roleItem
}
constructor MSUMLAssRole {class this typeName {typeItem ""} i_side association roleItem} {
set this [MSUMLTypeExpression::constructor $class $this $typeName $typeItem]
$this side $i_side
$this _association $association
[$association _roleSet] append $this
$this roleItem $roleItem
# Start constructor user section
# End constructor user section
return $this
}
method MSUMLAssRole::destructor {this} {
set ref [$this _association]
if {$ref != ""} {
[$ref _roleSet] removeValue $this
}
set ref [$this _owner]
if {$ref != ""} {
[$ref _roleSet] removeValue $this
}
# Start destructor user section
# End destructor user section
$this MSUMLTypeExpression::destructor
}
method MSUMLAssRole::ms2ot {this association side} {
$association setLabel role_$side [$this name]
set iAssRole [$this interfaceOfMe IUmlAssociationRole]
set mult [$iAssRole property multiplicity]
if {[$iAssRole property IsOrdered] == "1"} {
set mulSpec "{ordered}\n"
}
set mulSpec ""
if {$mult == "1"} {
$association setProp mult_kind_$side one comp
} elseif {$mult == "0..1"} {
$association setProp mult_kind_$side optional comp
} else {
if {$mult != "0..*"} {
regsub {\.\.\*} $mult {+} toAppendSpec
regsub {\.\.} $toAppendSpec {-} toAppendSpec2
set mulSpec "$mulSpec $toAppendSpec2"
}
$association setProp mult_kind_$side many comp
}
if [llength $mulSpec] {
$association setProp mult_spec_$side $mulSpec
}
}
method MSUMLAssRole::ot2ms {this package} {
set typeClass [$this type]
set ass [$this association]
set uClass [$typeClass msUmlObject]
set uAss [$ass msUmlObject]
global trans
$trans begin
$uClass setAsTo
$uAss setAsFrom
set name "<noOTName>"
set hasName 0
set roleItem [$this roleItem]
if ![$roleItem isNil] {
set hasName 1
set name [$roleItem name]
}
puts "\t\tRole '$name'"
# creation
set newRole [$package createRole $name]
set mySide [$this side]
set iNewRole [$newRole getInterface IUmlAssociationRole]
# Multiplicty
set smAss [$ass smAssociation]
set otMultiplicity [$smAss getPropertyValue mult_kind_$mySide]
set umlMultiplicity "0..*"
if {$otMultiplicity == "one"} {
set umlMultiplicity "1"
}
if {$otMultiplicity == "many"} {
set umlMultiplicity "0..*"
}
set constraintLabel [$smAss getLabel 0 constraint_$mySide]
if ![$constraintLabel isNil] {
regsub -all {\-} [$constraintLabel value] ".." temp
regsub -all {\+} $temp "..*" umlMultiplicity
}
$iNewRole property Multiplicity $umlMultiplicity
# Aggregation
set assType [[$smAss getConnector] type]
if {$assType == "aggregation" && $mySide == "end"} {
$iNewRole property IsAggregate 1
} else {
$iNewRole property IsAggregate 0
}
set orderedLabel [$smAss getLabel 0 mult_spec_$mySide]
if ![$orderedLabel isNil] {
$iNewRole property IsOrdered \
[string match *ordered* [$orderedLabel value]]
} else {
$iNewRole property IsOrdered 0
}
#$iNewRole property IsChangeable 1
$iNewRole property isNavigable $hasName
$iNewRole delete
$trans commit
return $newRole
}
method MSUMLAssRole::promoter {this association} {
$this MSUMLTypeExpression::promoter
$this _association $association
$association addRole $this
set typeObject [$this getTypeAsUML]
MSUMLClass promote $typeObject
#$this _type $typeObject
}
# Do not delete this line -- regeneration end marker
method MSUMLAssRole::association {this args} {
if {$args == ""} {
return [$this _association]
}
set ref [$this _association]
if {$ref != ""} {
[$ref _roleSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _roleSet] append $this
}
$this _association $obj
}
method MSUMLAssRole::owner {this args} {
if {$args == ""} {
return [$this _owner]
}
set ref [$this _owner]
if {$ref != ""} {
[$ref _roleSet] removeValue $this
}
set obj [lindex $args 0]
if {$obj != ""} {
[$obj _roleSet] append $this
}
$this _owner $obj
}