file Reading stereotype property table values

1 year 4 months ago #6285 by jvalenzuela
I'm trying to retrieve the values assigned to a stereotype property table. To start with, a test stereotype is created with a property table containing a single property:

Next, the stereotype is attached to the target model element, a state machine in this case, and given a value for the single table property:

Now, using Java API methods to try and access this value:
stateMachine.getExtension().size() == 1 // indicating there is indeed a single stereotype associated with the state machine model element.
stateMachine.getExtension().get(0).getName() == "testStereotype" // indicating the expected stereotype.

Beyond those two methods, I can't seem to get any further in accessing the properties themselves:
Stereotype st = stateMachine.getExtension().get(0);

stateMachine.getProperties(st) == null // This indicates there are no typed property tables.
stateMachine.getProperty(st, "prop1") == null // Accessing the property via name returns nothing.
stateMachine.getProperties().size() == 0 // The element has no property tables.

Thank you,
Jason Valenzuela

Please Log in or Create an account to join the conversation.

1 year 4 months ago #6302 by jvalenzuela
I believe I've found the reason why I could not retrieve property table values. It seems getProperty() and friends return null unless the property value has been modified. Consider the following sequence of events:
  1. Define a module with a stereotype containing a property table that has a property with some default value.
  2. Deploy the module and add the stereotype to an element.
  3. The Modelio editor will now show the property table with the default value, yet getProperty() will return null when trying to retrieve the value.
  4. Change the value with the Modelio editor. The new value can be the same as the default value; it doesn't matter.
  5. getProperty() will now return the actual value.

Seems like a bug. This behavior exists in Modelio v4.0.01.

Please Log in or Create an account to join the conversation.

Moderators: tmachmaab
Time to create page: 0.291 seconds
^ Back to Top