DSD-DBS / py-capellambse

A Python 3 headless implementation of the Capella modeling tool.
https://dsd-dbs.github.io/py-capellambse/
Apache License 2.0
53 stars 10 forks source link

Offering a (semi-)automated way of fixing a corrupted Model (duplicated UUIDs) #152

Open ewuerger opened 2 years ago

ewuerger commented 2 years ago

An issue on the context-diagrams extension should have been posted here. I tested the repair mechanism from Capella on our corrupted TestModel (from 856fb8e) and it only did something to the .aird file.

For now dealing with duplicated UUIDs is to be done manually, by hand. In this issue we may find a way to automate fixing such models.

When checking out 856fb8e and instantiating a MelodyModel instance one is greeted with: CorruptModelError: Duplicate UUID 'a7acb298-d14b-4707-a419-fea272434541' within fragment tests/data/melodymodel/5_2/Melody Model Test.capella

In our easy case we deal with 2 functions with the same UUID teach potions and Teaching: image image

Now the UUID was involved in a FunctionChain: image

and an allocation: image

where the user should know which of the function was the right one for the FunctionalChain and allocation. In our case here we knew that teach Potions just needed a new UUID. After fixing this we then needed to deal with its port that also had the same UUID as the port of Teaching. It seems that Teaching was copied but without creating a new UUID for it via Capella. I know that our create API (MelodyLoader.new_uuid) did not cause this corruption.

From re-investigating this easy case again I see that there is already a decision to be made which requires artificial knowledge about the model content. That is why I'd say the maximum we could work on is an interactive stepper that assists the user on fixing the xml tree in the .capella, .melodymodel or even (god forbid) all .fragment files in the command line.

vik378 commented 2 years ago

I'm not sure, @ewuerger, if we should keep both functions in that example. I think it is better to replicate the way Capella handles this - most likely only one of these functions gets to the project explorer and the older one gets "masked". If that is the case I would then delete the older duplicate. In your example I assume that the original "Teaching" thing most likely evolved into "teach potions" which would be consistent with verb-noun naming template for functions.