home *** CD-ROM | disk | FTP | other *** search
/ PC World 1998 October / PCWorld_1998-10_cd.bin / software / prehled / komix / DATA.Z / drssmmodel.tcl < prev    next >
Text File  |  1997-08-29  |  7KB  |  232 lines

  1. #---------------------------------------------------------------------------
  2. #
  3. #      (c)     Cayenne Software Inc.    1997
  4. #
  5. #      File:           @(#)drssmmodel.tcl    /main/titanic/4
  6. #      Author:         <generated>
  7. #      Description:
  8. #---------------------------------------------------------------------------
  9. # SccsId = @(#)drssmmodel.tcl    /main/titanic/4   29 Aug 1997 Copyright 1997 Cayenne Software Inc.
  10.  
  11. # Start user added include file section
  12. require reqdriver.tcl
  13. # End user added include file section
  14.  
  15.  
  16. Class DrsSMModelObject : {Object} {
  17.     method destructor
  18.     constructor
  19.     method initializeSM
  20.     method getItemDefs
  21.     method getSMObjects
  22.     method getSMModel
  23.     method getChildObjects
  24.     method localDefined
  25.     method installRefs
  26.     method showClassFeatures
  27.     method showSMObjects
  28.     attribute childObjects
  29.     attribute smObjects
  30.     attribute itemDefs
  31.     attribute initializedSM
  32.     attribute smModel
  33. }
  34.  
  35. method DrsSMModelObject::destructor {this} {
  36.     # Start destructor user section
  37.         if {[$this initializedSM]  && [llength [$this smModel]]} {
  38.             [$this smModel] delete
  39.         }
  40.     # End destructor user section
  41. }
  42.  
  43. constructor DrsSMModelObject {class this levelVersions} {
  44.     set this [GCObject::constructor $class $this]
  45.     # Start constructor user section
  46.     OtkRegister::semanticModel
  47.         $this levelVersions $levelVersions
  48.         $this initializedSM 0
  49.     # End constructor user section
  50.     return $this
  51. }
  52.  
  53. method DrsSMModelObject::initializeSM {this} {
  54.      [.main messageArea] message "Loading Semantic Model ..."
  55.     set level [$this level]
  56.         set childObjects ""
  57.         set itemDefs ""
  58.         set smObjects ""
  59.  
  60.         set configV [$this getConfigVersion]
  61.         set levelV [$level selectedVersion $configV]
  62.         set levelVersions [$this levelVersions]
  63.         if {[$configV isNil] || [$levelV isNil]} {
  64.             $this initializedSM 1
  65.             return $this
  66.         }
  67.         if {[[$this getPhase] name] == "Implementation"} {
  68.             $this initializedSM 1
  69.             return $this
  70.         }
  71.  
  72.         GCControl collect
  73.         set smModel [$this getSMModel]
  74.         $this smModel $smModel
  75.     set smTypeNames [m4_var get M4_doors_semantic_types]
  76.     if ![llength $smTypeNames] {
  77.         set smTypeNames {Class "UCD UseCase"}
  78.         m4_var set M4_doors_semantic_types $smTypeNames
  79.         m4_var saveStatus M4_doors_semantic_types 0
  80.     }
  81.         foreach smRealTypeName $smTypeNames {
  82.         set smType [SMTypeDB::find $smRealTypeName]
  83.         if [$smType isNil] {
  84.         continue
  85.         }
  86.             set smTypeName [ReqDriver::getSMTypeName $smType]
  87.             foreach smNode [$smModel getSMObjects $smType] {
  88.                 set workItem [$smNode getWorkItem]
  89.                 if [$workItem isNil] {
  90.                     continue
  91.                 }
  92.                 set systemV [$workItem owner]
  93.                 set system [$systemV system]
  94.                 if [$this localDefined $workItem] {
  95.                     lappend childObjects [$smNode getWorkItem].$smTypeName
  96.                     lappend itemDefs [$smNode getWorkItem].$smTypeName
  97.                     lappend smObjects $smNode
  98.                 } 
  99.             }
  100.         }
  101.         $this childObjects $childObjects
  102.         $this itemDefs $itemDefs
  103.         $this smObjects $smObjects
  104.         $this initializedSM 1
  105. }
  106.  
  107. method DrsSMModelObject::getItemDefs {this} {
  108.     if ![$this initializedSM] {
  109.             $this initializeSM
  110.         }
  111.         return [$this itemDefs]
  112. }
  113.  
  114. method DrsSMModelObject::getSMObjects {this} {
  115.     if ![$this initializedSM] {
  116.             $this initializeSM
  117.         }
  118.         return [$this smObjects]
  119. }
  120.  
  121. method DrsSMModelObject::getSMModel {this} {
  122.         set smModel [$this smModel]
  123.         if [llength $smModel] {
  124.             return $smModel
  125.         }
  126.         set level [$this level]
  127.         set configV [$this getConfigVersion]
  128.         set levelV [$level selectedVersion $configV]
  129.         set smModel [SM[$level ORB_class]Model new $configV $levelV]
  130.         $this smModel $smModel
  131.         return $smModel
  132. }
  133.  
  134. method DrsSMModelObject::getChildObjects {this} {
  135.     if ![$this initializedSM] {
  136.             $this initializeSM
  137.         }
  138.         return [$this childObjects]
  139. }
  140.  
  141. method DrsSMModelObject::localDefined {this workItem} {
  142.     set localSysV [[ClientContext::global] currentSystem]
  143.     if [$localSysV isNil]  {
  144.         return 1
  145.     }
  146.     set owner [$workItem owner]
  147.     if [$owner isA Graph] {
  148.         return 1
  149.     }
  150.     return [$owner isSame $localSysV] 
  151. }
  152.  
  153. method DrsSMModelObject::installRefs {this} {
  154.     set dxlCommand ""
  155.     set parentLevelId [$this parentLevelId]
  156.     foreach smObject  [$this getSMObjects] {
  157.         set workItem [$smObject getWorkItem]
  158.         set systemV [$workItem owner]
  159.         if [$systemV isA Graph] {
  160.         # scope is diagram
  161.         set graph $systemV
  162.         set system [$graph system]
  163.         set systemV [$system selectedVersion [$this getConfigVersion]]
  164.         } else {
  165.         set system [$systemV system]
  166.         }
  167.         set drsItem [DrsSMItemObject new $smObject $system [ReqDriver::getVersion $systemV]]
  168.         $drsItem dxlCommand $dxlCommand
  169.         set dxlResult [$drsItem install]
  170.         if ![llength $dxlResult] {
  171.         return
  172.         }
  173.     }
  174.     return "1"
  175. }
  176.  
  177. method DrsSMModelObject::showClassFeatures {this majorOper minorOper} {
  178.     set confV [$this getConfigVersion]
  179.         set dxlCommand [$this dxlCommand]
  180.         foreach smObject [$this getSMObjects] {
  181.                 set workItem [$smObject getWorkItem]
  182.         set item [$smObject getItem]
  183.                 set systemV [$workItem owner]
  184.         if ![$systemV isA SystemVersion] {
  185.             # non class items
  186.             continue
  187.         }
  188.         set matrix [$systemV findFileVersion -byItemAndType $item cdm]
  189.         if [$matrix isNil] {
  190.             continue
  191.         }
  192.         $matrix loadRowData "name_type" rows
  193.         set file [$matrix file]
  194.         foreach rowData $rows {
  195.             foreach item [lindex $rowData 1] {
  196.             set workItem [$systemV findDefinition $item $confV]
  197.             set itemType [$item type]
  198.             if {$itemType == "de" || $itemType == "pe"} {
  199.                 set drsQItem [DrsQItemObject new $workItem \
  200.                         $file [ReqDriver::getVersion $matrix]]
  201.                 $drsQItem qualifier [$item qualifier]
  202.                 $drsQItem dxlCommand $dxlCommand
  203.                 $drsQItem filter $majorOper $minorOper 
  204.             }
  205.             }
  206.         }
  207.     }
  208. }
  209.  
  210. method DrsSMModelObject::showSMObjects {this majorOper minorOper} {
  211.         set dxlCommand [$this dxlCommand]
  212.         foreach smObject [$this getSMObjects] {
  213.                 set workItem [$smObject getWorkItem]
  214.                 set systemV [$workItem owner]
  215.         if [$systemV isA Graph] {
  216.             # scope is diagram
  217.             set graph $systemV
  218.             set system [$graph system]
  219.             set systemV [$system selectedVersion [$this getConfigVersion]]
  220.         } else {
  221.             set system [$systemV system]
  222.         }
  223.                 set drsItem [DrsSMItemObject new $smObject $system [ReqDriver::getVersion $systemV]]
  224.                 $drsItem dxlCommand $dxlCommand
  225.                 $drsItem filter $majorOper $minorOper
  226.         }
  227.  
  228. }
  229.  
  230. # Do not delete this line -- regeneration end marker
  231.  
  232.