Book a Demo

Author Topic: Accessing Stereotypes via VBscr: Strange behaviour  (Read 3128 times)

Illo

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Accessing Stereotypes via VBscr: Strange behaviour
« on: December 18, 2010, 02:39:15 am »
Hello,

I observed a strange behaviour of EA while setting and reading multiple stereotypes of a UML class:
If I set two stereotypes via the properties dialog, the script reads only one of them.

If I set multiple stereotypes via script and try to read them afterwards, only one or two of them will be read depending of the call of theElement.Update.

It seems to me that the bahaviour of EA is not reliable.

Does anyone encountered the same problems and does have a good explanation for this behaviour?
Perhaps EA is not really designed for assigning more than one stereotypes to elements? I have no idea.

Regards,
Oliver

PS: I'm working here with EA 8.0.861 CE

Here's my code for testing:
Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: AccessStereotypes
' Author: Oliver Roeke
' Purpose: Test the access to stereotypes
' Date: 17.12.2010
'
sub main
      Session.Output( "AccessStereotypes" )
      
      Repository.EnsureOutputVisible "Script"
      
      ' Get the currently selected element in the tree to work on
      dim theElement as EA.Element
      set theElement = Repository.GetTreeSelectedObject()
      
      if not theElement is nothing and theElement.ObjectType = otElement then
            ' Try to read multiple stereotypes which have been set via element's property dialog.
            ' Expected result: utility,type
            Session.Output( "Stereotypes of " & theElement.Name & ": " & theElement.Stereotype )
            ' System behaviour: utility -> type missing -> bug
            
            ' Try to set multiple stereotypes tread,utility via script
            theElement.Stereotype = "thread,utility"
            theElement.Update
            
            ' Try to read them:
            ' Expected result: tread,utility
            Session.Output( "Stereotypes of " & theElement.Name & ": " & theElement.Stereotype )
            ' System behaviour: utility -> type missing -> bug
            
            
      end if
end sub

main

Illo

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: Accessing Stereotypes via VBscr: Strange behav
« Reply #1 on: December 18, 2010, 03:09:11 am »
Hello @ all,

I found the bug.
Accoding to the basic law of software engineering:
"If debugging is the process of removing bugs, programming must be the process for putting them in."
I'm responsible for the bug:
Replacing '.Stereotype' by '.StereotypeEx' in my coded will solve the problem.

But nevertheless trying to set more than on stereotypes by using the property '.Stereotype' leads to courious behaviour, espacially when combined with setting stereotypes via property dialog.

Greetings,
Oliver


Quote
Hello,

I observed a strange behaviour of EA while setting and reading multiple stereotypes of a UML class:
If I set two stereotypes via the properties dialog, the script reads only one of them.

If I set multiple stereotypes via script and try to read them afterwards, only one or two of them will be read depending of the call of theElement.Update.

It seems to me that the bahaviour of EA is not reliable.

Does anyone encountered the same problems and does have a good explanation for this behaviour?
Perhaps EA is not really designed for assigning more than one stereotypes to elements? I have no idea.

Regards,
Oliver

PS: I'm working here with EA 8.0.861 CE

Here's my code for testing:
Code: [Select]
option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: AccessStereotypes
' Author: Oliver Roeke
' Purpose: Test the access to stereotypes
' Date: 17.12.2010
'
sub main
      Session.Output( "AccessStereotypes" )
      
      Repository.EnsureOutputVisible "Script"
      
      ' Get the currently selected element in the tree to work on
      dim theElement as EA.Element
      set theElement = Repository.GetTreeSelectedObject()
      
      if not theElement is nothing and theElement.ObjectType = otElement then
            ' Try to read multiple stereotypes which have been set via element's property dialog.
            ' Expected result: utility,type
            Session.Output( "Stereotypes of " & theElement.Name & ": " & theElement.Stereotype )
            ' System behaviour: utility -> type missing -> bug
            
            ' Try to set multiple stereotypes tread,utility via script
            theElement.Stereotype = "thread,utility"
            theElement.Update
            
            ' Try to read them:
            ' Expected result: tread,utility
            Session.Output( "Stereotypes of " & theElement.Name & ": " & theElement.Stereotype )
            ' System behaviour: utility -> type missing -> bug
            
            
      end if
end sub

main