Book a Demo

Author Topic: Source, target, geometry, and visibility of multiplicity.  (Read 4346 times)

IanCornwell

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Source, target, geometry, and visibility of multiplicity.
« on: June 27, 2023, 07:25:20 pm »
Our community has a set of models that use a common UML profile that was created 20 years ago and is currently being updated. We use our own stereotyped composition association, and for reasons now forgotten it has the part as source end and the composite at the target end – so it must be drawn from part to composite. That way round is unexpected to the majority of today’s modellers, so we are updating our profile to use a more conventional kind of association instead. For consistency of the model – at least how the modellers see “Source” and “Target” when they inspect association properties – we would also like to update the existing associations. There are thousands, so we would automate this. I have been exploring EA scripting for this.
A script successfully navigates to all Connector objects, identifies the right ones, and manipulates their properties. Properties that are objects are read-only, but the leaf-level attributes can be changed, and I seem to have successfully swapped ClientID and SupplierID, and ClientEnd and SupplierEnd internal properties like Aggregation, Role, Cardinality and Navigable – so the diagrams basically look the same as before.

For a minority of associations this breaks the geometry of the link on the diagram. I found DiagramLink.Geometry, but I couldn’t find any documentation of the Geometry format, or a way to know which links will break, and how to correct them. As a compromise it may be feasible to manually look through a hundred diagrams and force link redrawing by a minute adjustment of the positions of affected classes.

A more severe problem is that some multiplicities disappear from diagrams. All our compositions have multiplicity stated at the part end (which was the source but will now be the target) and not at the composite end (which is implicitly always 1). The UI has Visibility | Set Label Visibility which brings up a dialog of selection boxes with various labels, and in that the multiplicity of the composite end is unchecked (hidden) – or after supplier-client swapping it’s the part end multiplicity that is hidden (but we need to see it). I can change this in the UI, but I want to avoid doing that for one thousand associations.

I have read that HDN=0 / HDN = 1 within geometry determines visibility, but that doesn’t agree with what I am seeing - where the Geometry strings for links with missing visibility don’t have any HDN=1, and where if I manually change the label visibility in the UI, to force the multiplicity of the part end to appear, the only change in the Geometry strings is to nudge what looks like coordinates by 1 – no more or fewer fields and no change to HDNs.

Any ideas of a better approach to swapping the roles of source and target with respect to the composition?
If not, any information on how the visibility of multiplicities could be scripted, given the apparent non-use of HDN for this?
And is there any idea how to avoid needing to manually force a redraw of diagram links with broken geometry?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Source, target, geometry, and visibility of multiplicity.
« Reply #1 on: June 27, 2023, 07:46:27 pm »
Usually the trick is to figure out how exactly EA is determining to show/hide a multiplicity.
It's somewhere in the database, but you need to figure out exactly where.

I would start looking at t_DiagramLinks and t_Diagram. For some reason they sometimes hide information that should be stored on the diagramlink/diagramobject on the diagram level. Field such as StyleEx, PDATA etc.. with lots of key=value pairs are the usual suspects.

Geert

IanCornwell

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Source, target, geometry, and visibility of multiplicity.
« Reply #2 on: June 28, 2023, 11:07:24 pm »
I looked at the XMI in case of inspiration, because that is more familiar to me than the database. This made me realise that I was probably mistaken when I said there were no "HDN=1" in the Geometry strings - I must have been looking at slightly truncated strings having used the copy function of the debugger. There are indeed "HDN=1" appearing after "LRB" in the Geometry strings for the affected associations. So I can try finding the HDN=1 after LRB and changing to HDN=0, and I expect this will work.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Source, target, geometry, and visibility of multiplicity.
« Reply #3 on: July 04, 2023, 04:42:02 pm »
I looked at the XMI in case of inspiration because that is more familiar to me than the database. This made me realise that I was probably mistaken when I said there were no "HDN=1" in the Geometry strings - I must have been looking at slightly truncated strings, having used the copy function of the debugger. There are indeed "HDN=1" appearing after "LRB" in the Geometry strings for the affected associations. So I can try finding the HDN=1 after LRB and changing to HDN=0, and I expect this will work.
Hi Ian,

I hope you've been able to sort this out.  You may be interested in the other ways connector labels can be shown/hidden on diagrams.  See:https://sparxsystems.com/forums/smf/index.php/topic,47898.msg278745.html#msg278745

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!