Book a Demo

Author Topic: Attribute move  (Read 9476 times)

naxx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Attribute move
« 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

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Attribute move
« Reply #1 on: May 12, 2017, 10:47:41 pm »
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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attribute move
« Reply #2 on: May 13, 2017, 12:00:23 am »
Oliver is right. You "could" change t_attribute.Object_ID, but I'm not sure if that's the best idea.

q.

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: Attribute move
« Reply #3 on: May 13, 2017, 01:35:33 am »
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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13517
  • Karma: +573/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attribute move
« Reply #4 on: May 13, 2017, 02:48:51 pm »
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

chrislro

  • EA User
  • **
  • Posts: 30
  • Karma: +2/-0
    • View Profile
Re: Attribute move
« Reply #5 on: March 24, 2022, 01:31:11 am »
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), which also does not end satisfyingly.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13517
  • Karma: +573/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attribute move
« Reply #6 on: March 24, 2022, 01:46:34 am »
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

chrislro

  • EA User
  • **
  • Posts: 30
  • Karma: +2/-0
    • View Profile
Re: Attribute move
« Reply #7 on: March 24, 2022, 05:13:16 am »
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!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attribute move
« Reply #8 on: March 24, 2022, 07:46:40 am »
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.