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 >
Text File  |  1997-08-29  |  5KB  |  188 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)msumlassro.tcl    /main/titanic/2
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)msumlassro.tcl    /main/titanic/2   29 Aug 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. # End user added include file section
  13.  
  14. #require "msumltypee.tcl"
  15.  
  16. Class MSUMLAssRole : {MSUMLTypeExpression} {
  17.     constructor
  18.     method destructor
  19.     method ms2ot
  20.     method ot2ms
  21.     method promoter
  22.     method association
  23.     method owner
  24.     attribute side
  25.     attribute _association
  26.     attribute _owner
  27.     attribute roleItem
  28. }
  29.  
  30. constructor MSUMLAssRole {class this typeName {typeItem ""} i_side association roleItem} {
  31.     set this [MSUMLTypeExpression::constructor $class $this $typeName $typeItem]
  32.     $this side $i_side
  33.     $this _association $association
  34.     [$association _roleSet] append $this
  35.     $this roleItem $roleItem
  36.     # Start constructor user section
  37.     # End constructor user section
  38.     return $this
  39. }
  40.  
  41. method MSUMLAssRole::destructor {this} {
  42.     set ref [$this _association]
  43.     if {$ref != ""} {
  44.         [$ref _roleSet] removeValue $this
  45.     }
  46.     set ref [$this _owner]
  47.     if {$ref != ""} {
  48.         [$ref _roleSet] removeValue $this
  49.     }
  50.     # Start destructor user section
  51.     # End destructor user section
  52.     $this MSUMLTypeExpression::destructor
  53. }
  54.  
  55. method MSUMLAssRole::ms2ot {this association side} {
  56.     $association setLabel role_$side [$this name]
  57.     set iAssRole [$this interfaceOfMe IUmlAssociationRole] 
  58.     set mult [$iAssRole property multiplicity]
  59.     if {[$iAssRole property IsOrdered] == "1"} {
  60.         set mulSpec "{ordered}\n"
  61.     }
  62.     set mulSpec ""
  63.     if {$mult == "1"} {
  64.         $association setProp mult_kind_$side one comp
  65.     } elseif {$mult == "0..1"} {
  66.         $association setProp mult_kind_$side optional comp
  67.     } else {
  68.         if {$mult != "0..*"} {
  69.         regsub {\.\.\*} $mult {+} toAppendSpec
  70.         regsub {\.\.} $toAppendSpec {-} toAppendSpec2
  71.         set mulSpec "$mulSpec $toAppendSpec2"
  72.         }
  73.         $association setProp mult_kind_$side many comp
  74.     }
  75.     if [llength $mulSpec] {
  76.         $association setProp mult_spec_$side $mulSpec
  77.     }
  78. }
  79.  
  80. method MSUMLAssRole::ot2ms {this package} {
  81.     set typeClass [$this type]    
  82.     set ass [$this association]
  83.     
  84.     set uClass [$typeClass msUmlObject]
  85.     set uAss [$ass msUmlObject]
  86.  
  87.     global trans
  88.     $trans begin
  89.     $uClass setAsTo
  90.     $uAss setAsFrom
  91.  
  92.     set name "<noOTName>"
  93.     set hasName 0
  94.     set roleItem [$this roleItem]
  95.     if ![$roleItem isNil] {
  96.         set hasName 1
  97.         set name [$roleItem name]
  98.     }
  99.     puts "\t\tRole '$name'"
  100.  
  101.  
  102.     # creation
  103.     set newRole [$package createRole $name]
  104.     set mySide [$this side]
  105.     set iNewRole [$newRole getInterface IUmlAssociationRole]
  106.  
  107.     # Multiplicty
  108.     set smAss [$ass smAssociation]
  109.     set otMultiplicity [$smAss getPropertyValue mult_kind_$mySide]
  110.     set umlMultiplicity "0..*"
  111.     if {$otMultiplicity == "one"} {
  112.         set umlMultiplicity "1"
  113.     } 
  114.     if {$otMultiplicity == "many"} {
  115.         set umlMultiplicity "0..*"
  116.     } 
  117.     set constraintLabel [$smAss getLabel 0 constraint_$mySide]
  118.     if ![$constraintLabel isNil] {
  119.         regsub -all {\-} [$constraintLabel value] ".." temp
  120.         regsub -all {\+} $temp "..*" umlMultiplicity 
  121.     }
  122.     $iNewRole property Multiplicity $umlMultiplicity
  123.  
  124.     # Aggregation
  125.     set assType [[$smAss getConnector] type]
  126.     if {$assType == "aggregation" && $mySide == "end"} {
  127.         $iNewRole property IsAggregate 1
  128.     } else {
  129.         $iNewRole property IsAggregate 0
  130.     }
  131.  
  132.     set orderedLabel [$smAss getLabel 0 mult_spec_$mySide]
  133.     if ![$orderedLabel isNil] {
  134.         $iNewRole property IsOrdered  \
  135.             [string match *ordered* [$orderedLabel value]] 
  136.     } else {
  137.         $iNewRole property IsOrdered  0
  138.     }
  139.     #$iNewRole property IsChangeable 1
  140.     $iNewRole property isNavigable $hasName
  141.     $iNewRole delete
  142.     $trans commit
  143.     return $newRole
  144. }
  145.  
  146. method MSUMLAssRole::promoter {this association} {
  147.     $this MSUMLTypeExpression::promoter
  148.     $this _association $association
  149.     $association addRole $this
  150.     set typeObject [$this getTypeAsUML]
  151.     MSUMLClass promote $typeObject
  152.     #$this _type $typeObject
  153. }
  154.  
  155. # Do not delete this line -- regeneration end marker
  156.  
  157. method MSUMLAssRole::association {this args} {
  158.     if {$args == ""} {
  159.         return [$this _association]
  160.     }
  161.     set ref [$this _association]
  162.     if {$ref != ""} {
  163.         [$ref _roleSet] removeValue $this
  164.     }
  165.     set obj [lindex $args 0]
  166.     if {$obj != ""} {
  167.         [$obj _roleSet] append $this
  168.     }
  169.     $this _association $obj
  170. }
  171.  
  172. method MSUMLAssRole::owner {this args} {
  173.     if {$args == ""} {
  174.         return [$this _owner]
  175.     }
  176.     set ref [$this _owner]
  177.     if {$ref != ""} {
  178.         [$ref _roleSet] removeValue $this
  179.     }
  180.     set obj [lindex $args 0]
  181.     if {$obj != ""} {
  182.         [$obj _roleSet] append $this
  183.     }
  184.     $this _owner $obj
  185. }
  186.  
  187.  
  188.