Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: McMannus on August 08, 2013, 08:37:45 pm

Title: Element.synchTaggedValues Confusion
Post by: McMannus on August 08, 2013, 08:37:45 pm
Hi all,

I have an element with stereotype "InputFailureMode", which should additionally get the stereotype "Input Event" (Input Event contains several Tagged Values).

The code looks like this:
Code: [Select]
if (elem.Stereotype.Equals(FailurePropagationModel.STEREO_INPUTFAILUREMODE) {
                    elem.StereotypeEx += "," + STEREO_INPUTEVENT;
                    elem.Update();
                    System.Diagnostics.Debug.WriteLine("FM Name: " + elem.Name + " Stereo: " + elem.Stereotype + " StereoEx: " + elem.StereotypeEx);
                    System.Diagnostics.Debug.WriteLine("Synching: "+elem.SynchTaggedValues(FailurePropagationModel.PROFILE_NAME, FailurePropagationModel.STEREO_INPUTFAILUREMODE));
                    System.Diagnostics.Debug.WriteLine("Synching: " + elem.SynchTaggedValues(PROFILE_NAME, STEREO_INPUTEVENT));
                }

For any strange reason, the output of those lines is:
Code: [Select]
FM Name: NewElement115 Stereo: InputFailureMode StereoEx: InputFailureMode,Input Event
Synching: True
Synching: False

I don't understand, why the first synch succeeds while the second one doesn't. As background information, the element is created with the InputFailureMode-stereotype from the toolbox.

Please give me some enlightment  :)
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 08, 2013, 08:46:43 pm
Does this one help you further: http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1375916353?

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: McMannus on August 08, 2013, 08:53:19 pm
Not really, because the profile looks like this:
(https://dl.dropboxusercontent.com/u/15260967/screenshot%201.jpg)
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 08, 2013, 10:00:03 pm
I tried that. And, interestingly, I did not need to synch at all! The tags were immediately present after applying the stereotype(s). It seems that Sparx has done something with tagged values. Also if you remove the stereotype the tags go away (which was not the case with 9.3).

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: McMannus on August 08, 2013, 10:18:45 pm
Do you mean that SOMESTEREOTYPE's tags appear in the Tagged Values window after those lines?

Code: [Select]
elem.StereotypeEx += "," + SOMESTEREOTYPE;
elem.Update();
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 08, 2013, 11:34:31 pm
Yes. At least it did with my test MDG (build 1007).

Release notes for build 1005: Synchronizing tagged values for a stereotype will no longer duplicate inherited tagged values.

To me it looks like this has introduced a complete new behavior with tagged values.

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: McMannus on August 08, 2013, 11:39:29 pm
I also work with build 1007, but it doesn't work there.
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 09, 2013, 05:21:05 am
Can you try doing it manually? Create a plain class and assign the stereotypes from the ellipsis. That should add the tags.

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: Eve on August 09, 2013, 08:40:43 am
Quote
Release notes for build 1005: Synchronizing tagged values for a stereotype will no longer duplicate inherited tagged values.

To me it looks like this has introduced a complete new behavior with tagged values.
Release notes for version 10.

  Applying a stereotype to anything will now automatically add the tagged values specified by the stereotype.
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 09, 2013, 09:27:27 am
So doesn't that make SynchTaggedValues (/Profile) superfluous? The help does not tell.

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: KP on August 09, 2013, 09:40:46 am
Quote
So doesn't that make SynchTaggedValues (/Profile) superfluous? The help does not tell.

q.
Synchronizing still has its uses. It can restore deleted tags, and it can apply new tags when a profile changes.
Title: Re: Element.synchTaggedValues Confusion
Post by: qwerty on August 09, 2013, 08:04:00 pm
I see. But generally speaking you would not need to call synch with V10 as (my observation) adding the stereotype automatically adds the tagged values. Right?

q.
Title: Re: Element.synchTaggedValues Confusion
Post by: McMannus on August 14, 2013, 01:26:46 am
After long trial and error, I got the issue to work now.

The problem was that...

1) The stereotype I assigned to an element did not extend a metaclass.
2) when the stereotype extended a metaclass, it was apparently not the right one

Finally, I used the metaclass Property for the stereotype I wanted to assign to another one. I wasn't really able to figure out why metaclass DataType didn't work.