Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: naxx on May 12, 2017, 09:34:38 pm
-
Hello,
How I can move class attribute (in EA api Attribute instance) to another class?
Thanks for your answers.
Naxx
-
To the best of my knowledge you can´t. This is implemented by the UI and not exposed by the API as the parent ID is read-only:
ParentID | Long | Read only | Returns the ElementID of the element that this attribute is a part of.
However if you can live with the moved attribute having a new GUID you can use AddNew to build a new attribute at the correct target, copy all entries from the old one and delete that afterwards.
Oliver
-
Oliver is right. You "could" change t_attribute.Object_ID, but I'm not sure if that's the best idea.
q.
-
Oliver is right. You "could" change t_attribute.Object_ID, but I'm not sure if that's the best idea.
Interesting option here to manipulate the DB objects directly. Though I´d second the doubt as probably not even Sparx is applying that sort of change when moving items but using a layer in between instead which benefits from generic transactions et al. There are way too much things which could go wrong otherwise.
Oliver
-
In a similar case I just copied the properties of an existing attribute into a new one on a new parent.
I don't manipulate the database directly unless I really don't have any other choice.
Geert
-
Just found this thread about moving attributes.
I understand that the parentId is read-only, but is it still with 15.2 API not possible to script the move from one element to another? In the UI this is a simple drag & drop from source to target. I also understand the idea to copy attributes and methods instead, but also this is not quiet simple, as those can have a lot of child assets (e.g. multiple method parameters, each with a note, ...). I also saw a thread about "deep copy"(https://sparxsystems.com/forums/smf/index.php/topic,4702.0.html (https://sparxsystems.com/forums/smf/index.php/topic,4702.0.html)), which also does not end satisfyingly.
-
No, still a problem.
You can send a feature request using the link on the bottom of this page.
As a workaround you can set the objectID in the database directly using Repository.Execute, or else copy the properties one by one.
Geert
-
So, some scripting hours later ... moving attributes and methods works with Repository.Execute() setting the Object_ID. Great! Irritatingly the parentID for elements is read & write, so moving child elements is not an issue. I am really wondering why this not possible for attributes and methods as well. I'll leave a feature request as well ...
Thanks!
-
So, some scripting hours later ... moving attributes and methods works with Repository.Execute() setting the Object_ID. Great! Irritatingly the parentID for elements is read & write, so moving child elements is not an issue. I am really wondering why this not possible for attributes and methods as well. I'll leave a feature request as well ...
Thanks!
Well, that's what we call EAUI (EA Unique Interface). I'm no longer shaking my head (it's stiff already). EA could be such a great tool. In Germany we have a saying: Built with your hands and teared down with you arse. That's exactly what describes EA.
q.