Book a Demo

Author Topic: Replace diagramobject  (Read 7434 times)

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Replace diagramobject
« on: January 07, 2016, 11:15:27 pm »
Hi guys,

Background story: I tend to find lots of actors in various sub-packages that are really one and the same. So, I write a small program that can merge two actors, i.e. move all actor-use case links from one actor to the other, which works fine. Next step is to find all diagrams the obsolete actor is in, which also works fine.

Problem: I have the diagramobject representing the original actor and I have the new actor element. Is it then enough to set the element id of the diagrams object to the element id of the new actor? When I do this and then call Update() on the diagramobject I get a COMException with no message and an HResult of -2147221504

Any ideas?

Cheers
Knut

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Replace diagramobject
« Reply #1 on: January 07, 2016, 11:20:58 pm »
Sounds interesting. I would have expected this to work. I'll give it a try.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Replace diagramobject
« Reply #2 on: January 08, 2016, 12:42:37 am »
It it enough, I've done the same thing in the past.
But I do seem to remember some issues with the diagramObjects.

I just checked my scripts and I found this snippet
Code: [Select]
dim updateDiagramObjectSQL
'set the element of the diagramObject to the new action
updateDiagramObjectSQL = "update t_diagramobjects set object_id = "& callingActivity.ElementID &" where Diagram_ID = " & diagramObject.DiagramID & " and Object_ID = " & element.ElementID
Repository.Execute updateDiagramObjectSQL

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Replace diagramobject
« Reply #3 on: January 08, 2016, 01:25:57 am »
I just tried with 1224. Worked with no issue.

q.

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: Replace diagramobject
« Reply #4 on: January 08, 2016, 07:32:41 pm »
OK, thanks guys :-)

I'm on 1215. Nice to know that IS supposed to work, so I'll take another look.

cheers
Knut

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: Replace diagramobject
« Reply #5 on: January 08, 2016, 09:11:02 pm »
Still on build 1215.

first tried a direct update in the database: work perfectly.
then tried my program again (using the API): worked perfectly.

Yesterday I was at home, today at the office.  Don't know how that can affect this specific functionality.

cheers
Knut

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Replace diagramobject
« Reply #6 on: January 08, 2016, 09:36:27 pm »
According to this diagnosis: definitely your home  ;D

q.

Knut Paulsen

  • EA User
  • **
  • Posts: 82
  • Karma: +1/-0
    • View Profile
Re: Replace diagramobject
« Reply #7 on: January 08, 2016, 11:57:41 pm »
Yes, probably :-)
But still accessing the exact same database using the exact same code, but of course some network differences.
Will try at home again to see what happens.

cheers
Knut