Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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?
-
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
-
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:
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)
-
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
-
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 methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = "Phase_Basic"
q.
-
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
methBP.Stereotype = "aaBIF metadata::Phase_Basic"
methBP.StereotypeEx = "aaBIF metadata::Phase_Basic"
has same effect as using this
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?
-
t_xref is the table that also holds stereotype information. Have you also tried to JUST use stereotypeEx?
q.
-
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
-
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
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.
???
-
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
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
-
Hm, I'm using v12 :-(
Anyway, synchronizing all the objects isn't very handy for my needs.
-
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
-
I've tried and it works. Ok, this is just workaround for me, but thank you.
-
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?
-
Where is the need to synch if you just created it newly? It shall have all stereotype properties.
q.
-
Yes, I've just created new operation and added stereotype to it. Without synchronization I can't see any tagged values.
Libor
-
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
-
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.
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.
-
Not sure (EAUI). Try to add another update before setting the stereotype. I remember some weird behavior there.
q.
-
Also worth a try:
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
-
I just tried it and had no issue setting the stereotype.
q.
-
@Geert, qwerty
None of your workarounds works :-(
-
Does the element show "any" stereotype after your script did run?
Probably you should run a consistency check once on your DB.
q.
-
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
-
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
-
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.
-
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
-
Then it's "Sparx-completely" :-/
q.
-
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?
-
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