jmcklondonuk / drawio_enterprise_architect_integration

This project imports XMI files from Sparx System Enterprise Architect into Draw.io
MIT License
3 stars 1 forks source link

Fix for issue #2. Dependencies with stereotype 'realize' are handled.… #3

Open Marius-U opened 5 months ago

Marius-U commented 5 months ago

Dependency with stereotype 'realyze' is processed before Source and Destination elements are added to diagram resulting in exception to be raised. First, UML:Interface needs to be implemented since it is the Destination of the 'realize' dependency.

After, to handle the situation where 'realize' dependencies cannot be drawn because the source and destination elements do not exist yet when the script runs, I modifyed the code to defer the creation of these dependencies until all elements are imported. Here's the approach: 1) Modify the createMxGraphCells function to defer the creation of 'realize' dependencies. 2) After importing all elements, loop through the deferred 'realize' dependencies and attempt to draw them again.

Result is visible in the diagram:

Imported Diagram drawio

Marius-U commented 5 months ago

Note: There are some related UML objects that have not been exported since they belong to other packages but the Dependency to those is marked in the XML as stereotype 'mandatory' and 'optional'. Those cases have been ignored for the time being.

jmcklondonuk commented 5 months ago

Hi @Marius-U, thank you for implementing this! I think it needs a couple of things before I can accept your pull request.

  1. the deferred processing makes the algorithm hard to follow. Would you be able to simply change the order in var types = ['Class', 'ActionState', 'Dependency', 'Actor', 'UseCase', 'Component', 'Interface', 'Association']; so that 'Dependency' will be processed last? It means ['Class', 'ActionState', 'Actor', 'UseCase', 'Component', 'Interface', 'Association', 'Dependency']; should avoid the need for any deferred processing. This will simplify the code.
  2. we need to avoid code duplication of the block of code for geometry. If it has to be called twice, can it be a function? Maybe it needs to be called only once after applying step 1. Let's see.