Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: bilon on July 18, 2019, 10:52:32 pm

Title: Synchronize tagged values on operation
Post by: bilon on July 18, 2019, 10:52:32 pm
I'm adding new stereotype to a operation and I need to propagate all the operations tagged values to this operation. There's a method SynchTaggedValues but it exists just for elements. So, what to do with the operation?
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on July 18, 2019, 11:49:12 pm
if you do it correctly the tagged values should appear automatically after setting the stereotype.
Make sure to use StereotypeEx and the fully qualified stereotype name.

Geert
Title: Re: Synchronize tagged values on operation
Post by: bilon on July 19, 2019, 01:09:41 am
I'm used to use plain names, because EA UI does it this way. Anyway, even with fully qualified names, it doesn't work. Here is my code:
Code: [Select]
Set methBP = tab.Methods.AddNew("BASE", Empty)
methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = methBP.Stereotype
methBP.Update
tab.Methods.Refresh

What is strange, that when looking at the operation properties afterwards, both stereotypes are plain. It looks like this (name|stereotype|stereotypeEx):
BASE|Phase_Basic|Phase_Basic

Here is the image of my MDG profile:
(https://photos.app.goo.gl/bxCRgp4sXKkuUw2u7)
https://photos.app.goo.gl/bxCRgp4sXKkuUw2u7 (https://photos.app.goo.gl/bxCRgp4sXKkuUw2u7)

Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on July 19, 2019, 01:22:27 am
Don't use .stereotype, but ony StereotypeEx
Then you'll have to make sure you are using the correct fully qualified name. Check t_xref to be sure.
An image of the toolbox does not help in any way as neither the name of the UML profile as the name of the stereotypes are shown there.

Geert
Title: Re: Synchronize tagged values on operation
Post by: qwerty on July 19, 2019, 01:35:07 am
Code: [Select]
methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = methBP.Stereotype
Makes EA cut the stereo to its base name which you then feed in to Ex. Would be the same as
Code: [Select]
methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = "Phase_Basic"

q.
Title: Re: Synchronize tagged values on operation
Post by: bilon on July 19, 2019, 06:35:41 pm
I use both Stereotype and StereotypeEx, because EA UI does it this whay. When using StereotypeEx only, what shall I do with Stereotype? Leave it empty?

Anyway, using this
Code: [Select]
methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = "aaBIF metadata::Phase_Basic"
has same effect as using this
Code: [Select]
methBP.Stereotype = "aaBIF metadata::Phase_Basic"ode
methBP.StereotypeEx = methBP.Stereotype
both properties are without qualifier. So, how shall I code it?

By the way, both profile and stereotype are visible in the picture. I have emphasized it.

What is it t_xref?
Title: Re: Synchronize tagged values on operation
Post by: qwerty on July 19, 2019, 06:42:17 pm
t_xref is the table that also holds stereotype information. Have you also tried to JUST use stereotypeEx?

q.
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on July 19, 2019, 06:42:39 pm
Yes, use only .StereotypeEx, don't use .Stereotype at all.
EA will fill in the .Stereotype field for you based on what you set in StereotypeEx

What is shown in your picture is the toolbox panel name, and the toolbox item name.
They can be the same as the profile and stereotype, but don't have to be.

t_xref is the table where the fully qualified stereotype details are stored.

Geert
Title: Re: Synchronize tagged values on operation
Post by: bilon on July 19, 2019, 07:39:56 pm
Ok, I found this in the t_xref (in many rows)
@STEREO;Name=Phase_Basic;FQName=aaBIF metadata::Phase_Basic;@ENDSTEREO;
so my fully qualified name was ok.

My code looks like this
Code: [Select]
Set methBP = tab.Methods.AddNew("BASE", Empty)
methBP.StereotypeEx = "aaBIF metadata::Phase_Basic"
methBP.Update
tab.Methods.Refresh
but the result is still same - both stereotypes without qualifier and no taggad values on the method.

???
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on July 19, 2019, 07:48:24 pm
Ok, I found this in the t_xref (in many rows)
@STEREO;Name=Phase_Basic;FQName=aaBIF metadata::Phase_Basic;@ENDSTEREO;
so my fully qualified name was ok.

My code looks like this
Code: [Select]
Set methBP = tab.Methods.AddNew("BASE", Empty)
methBP.StereotypeEx = "aaBIF metadata::Phase_Basic"
methBP.Update
tab.Methods.Refresh
but the result is still same - both stereotypes without qualifier and no taggad values on the method.

???
The stereotype fields never show the fully qualified name, so that's OK.
The tagged values should have automatically been added.
I've never really used this on operation, so there might be a bug preventing the tagged values to be added directly.

In that case there's a workaround to call Synchronize stereotype, but that will dot it for all items with that stereotype.
Since v14 or v15 you use Repository.SynchProfile (string Profile, string Stereotype)

Geert
Title: Re: Synchronize tagged values on operation
Post by: bilon on July 19, 2019, 07:54:23 pm
Hm, I'm using v12 :-(
Anyway, synchronizing all the objects isn't very handy for my needs.
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on July 19, 2019, 08:03:11 pm
In v12 you can use the Repository.CustomCommand to do the same:

See this script for an example: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/UML%20Profile/Synchronize%20Steretoypes.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/UML%20Profile/Synchronize%20Steretoypes.vbs)

Geert
Title: Re: Synchronize tagged values on operation
Post by: bilon on July 19, 2019, 08:20:50 pm
I've tried and it works. Ok, this is just workaround for me, but thank you.
Title: Re: Synchronize tagged values on operation
Post by: bilon on August 27, 2020, 11:48:58 pm
Let me continue with this issue.

I experimented a bit with the element.SynchTaggedValues method and found that it works, but only on existing operations. If this is a new operation just created by the script, it does not work. Any idea why?
Title: Re: Synchronize tagged values on operation
Post by: qwerty on August 28, 2020, 01:10:13 am
Where is the need to synch if you just created it newly? It shall have all stereotype properties.

q.
Title: Re: Synchronize tagged values on operation
Post by: bilon on August 28, 2020, 06:21:08 pm
Yes, I've just created new operation and added stereotype to it. Without synchronization I can't see any tagged values.

Libor
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on August 28, 2020, 07:10:44 pm
Yes, I've just created new operation and added stereotype to it. Without synchronization I can't see any tagged values.

Libor
Then I guess you must have done something wrong.
Setting the stereotype correctly should automatically create the tagged values.

Synchronize is only needed to reflect changes in the stereotype when you have added or change tagged values on the stereotype.

Geert
Title: Re: Synchronize tagged values on operation
Post by: bilon on September 01, 2020, 12:53:18 am
Ok, here's the test case.

I have an element (it's selected in the project browser) without any operation. After running following script (adding a new operation and setting it's stereotype) I can see new operation, but no tagged values on it. But when uncommenting the last row of the script (synchronization of the stereotype), I can see all the tagged valued.

Code: [Select]
Dim elm As EA.Element
Dim meth As EA.Method
Set elm = Repository.GetTreeSelectedElements(0)
Set meth = elm.Methods.AddNew("OPER1", "")
meth.StereotypeEx = "aaBIF metadata::Phase_Basic"
meth.Update
elm.Methods.Refresh
'Repository.CustomCommand "Repository", "SynchProfile", "Profile=aaBIF metadata;Stereotype=Phase_Basic;"

And now tell me what I'm doing wrong.
Title: Re: Synchronize tagged values on operation
Post by: qwerty on September 01, 2020, 01:55:06 am
Not sure (EAUI). Try to add another update before setting the stereotype. I remember some weird behavior there.

q.
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on September 01, 2020, 04:01:50 pm
Also worth a try:

Code: [Select]
Dim elm As EA.Element
Dim meth As EA.Method
Set elm = Repository.GetTreeSelectedElements(0)
Set meth = elm.Methods.AddNew("OPER1", "aaBIF metadata::Phase_Basic")
meth.Update

Geert
Title: Re: Synchronize tagged values on operation
Post by: qwerty on September 02, 2020, 06:10:15 am
I just tried it and had no issue setting the stereotype.

q.
Title: Re: Synchronize tagged values on operation
Post by: bilon on September 05, 2020, 02:10:03 am
@Geert, qwerty
None of your workarounds works  :-(
Title: Re: Synchronize tagged values on operation
Post by: qwerty on September 05, 2020, 05:50:55 am
Does the element show "any" stereotype after your script did run?

Probably you should run a consistency check once on your DB.

q.
Title: Re: Synchronize tagged values on operation
Post by: bilon on September 11, 2020, 07:33:17 pm
I have run consistency check and reset ids, but it's still the same.
After running the script, new operation looks like this:

meth.Name=OPER1, meth.Stereotype=Phase_Basic, meth.StereotypeEx=Phase_Basic   
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on September 11, 2020, 08:14:21 pm
What does t_xref.description say about it?

I'm guessing the stereotype is somehow not correctly set to the fully qualified stereotype.
Possibly a synchronize fixes this problem.
This should be apparent in t_xref.

A possible cause could be a spelling error in the fully qualified stereotype name (e.g. uppercase instead of lowercase)
I've seen cases like that where one part works (case insensitive) but other parts don't (case sensitive)

Geert
Title: Re: Synchronize tagged values on operation
Post by: qwerty on September 11, 2020, 08:58:27 pm
A possible cause could be a spelling error in the fully qualified stereotype name (e.g. uppercase instead of lowercase)
I've seen cases like that where one part works (case insensitive) but other parts don't (case sensitive)
If I'm not completely wrong EA ignores the case of stereotype in all cases (pun intended!).

q.
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on September 11, 2020, 09:23:16 pm
A possible cause could be a spelling error in the fully qualified stereotype name (e.g. uppercase instead of lowercase)
I've seen cases like that where one part works (case insensitive) but other parts don't (case sensitive)
If I'm not completely wrong EA ignores the case of stereotype in all cases (pun intended!).

q.
It depends. It ignores the case in the quicklink, but not in the syntax validation when adding a connector fromt the toolbox.

I just spent a good 45 minutes trying to find out why I could create a stereotyped relation with the quicklinker, but not from the toolbox. :-\

Geert
Title: Re: Synchronize tagged values on operation
Post by: qwerty on September 11, 2020, 11:09:41 pm
Then it's "Sparx-completely" :-/

q.
Title: Re: Synchronize tagged values on operation
Post by: bilon on September 11, 2020, 11:18:22 pm
What I haven't mentioned, I'm using version 12. Let my friend to try in version 13 and - it works! Is there any change between versions 12 and 13, which could be the reason of the  difference?
Title: Re: Synchronize tagged values on operation
Post by: Geert Bellekens on September 12, 2020, 12:00:05 am
What I haven't mentioned, I'm using version 12. Let my friend to try in version 13 and - it works! Is there any change between versions 12 and 13, which could be the reason of the  difference?
Quite possible yes. Between v12 and the current v15.2 there has been a lot of improvements with regards to the handling of stereotypes.

Geert