Author Topic: Unknown element in DiagramObjects  (Read 3356 times)

jörg

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Unknown element in DiagramObjects
« on: December 17, 2020, 03:54:55 am »
Hi Specialists!

In my addin I'm facing a behaviour which I can't explain.

I'm iterating the DiagramObjects of a diagram and then for each DiagramObject I try to retrieve the related Element from the repository using the GetElementByID(ElementID)-Function of the Repository class to get further information about the element. The diagram is of course in the same repository.

This works very well for many diagrams but in one diagram the GetElementByID-Function throws an exception saying that it could not find the element ("Can't find matching ID"). The ObjectType is - of course - otDiagramObject and the GetType-Function of the DiagramObject class tells me it is a System_ComObject. The user (I don't have access to the EA project myself) searched the diagram and it's Elements and could not find any COM object. Re-saving the diagram (after a slight change) did not change anything. When he exports the package and imports it into a new project, the error is gone.

So I have the following questions (and hope for answers 8)):
1. Can anyone explain this behaviour?
2. How can I find out which element is causing the error?
3. Why is the error persistant over re-saving but disappears after exporting and re-importing into another project?

Question 2 is the most important one which I need an answer for. The others are for my curiosity

Thanks in advance,

Jörg

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13282
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Unknown element in DiagramObjects
« Reply #1 on: December 17, 2020, 04:29:39 am »
Hi Jörg,

You probably have a integrity issue here.

When you delete an element, EA will clean up it's dependencies such as connectors to/from this element, diagramObjects referencing this element etc..

Now suppose EA crashes before it was able to clean up all dependencies. You could end up with a diagramObject that points to an element that doesn't exist anymore.

Most of these issues will be fixed running the project integrity check.
XMI import export does it's own "integrity" check and won't create diagramObjects for non existing elements.

Geert

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1311
  • Karma: +120/-10
  • Its the results that count
    • View Profile
Re: Unknown element in DiagramObjects
« Reply #2 on: December 17, 2020, 08:54:38 am »
I think Geert has hit the nail on the head as I've had similar behaviour fixed by running the integrity checker.
Configure Tab>Integrity>Project Integrity
You can run the report before fixing
Needless to say back up first before attempting to fix just incase something nasty happens.


Merry Christmas



Happy to help
:)

jörg

  • EA User
  • **
  • Posts: 28
  • Karma: +0/-0
    • View Profile
Re: Unknown element in DiagramObjects
« Reply #3 on: December 18, 2020, 12:11:46 am »
Thanks for the answers, this was my guess, too.
In my special case I want to detect changes in a diagram or the elements it contains. For this purpose I iterate over the elements creating a hash value for comparision. So I decided to just ignore the missing element. I an element was removed from the diagram I see this in the diagrams "modified" date.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13282
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Unknown element in DiagramObjects
« Reply #4 on: December 18, 2020, 12:25:12 am »
A deleted elements seems an important enough change not be ignored.

Also I wouldn't necesarrily count on the diagrams modified date. There can be lots of reasons the modified date wasn't updated, but it was still changed.

Geert