Sparx Systems Forum
Enterprise Architect => Bugs and Issues => Topic started by: aloeffen on November 18, 2015, 12:34:16 am
-
When I create a composition relation from whole to part, I see that source is part and target is the whole; I would expect the other way around.
Is this correct behavior and if so, does anyone known where this is described (in the UML standard)?
Thanks in advance,
arjan
-
That has been discussed long and broad here. The Quick Linker offers to do it both ways. You just need to get used to it. It's like USB: the first try doesn't work. You swap it. And recognize that the first time it was correct ;D
q.
-
That has been discussed long and broad here. The Quick Linker offers to do it both ways. You just need to get used to it. It's like USB: the first try doesn't work. You swap it. And recognize that the first time it was correct ;D
q.
USBs exhibit non-quantum superpositions.
-
It is said that once the person that invented the USB plug will die, he will be laid to his grave, taken out and turned around (twice?).
This year is 100th anniversary of e=mc2. What would Einstein and esp. Heisenberg say about USB?
q.
-
For those that are annoyed by this source/target thing, I wrote a little script that sets them straight for compositions.
If you copy this script to a diagram group you can right click on a composition and execute the script for that single relation, or right click on a a diagram and do it for all relations in the diagram.
There is however something strange going on with the navigability. After reloading the diagram it shows arrow heads where it didn't show them before. I'm not sure why that happens.
Part 1 of the code
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Script Name: Set composition source and target
' Author: Geert Bellekens
' Purpose: Make sure that the whole end is always the source, and the part end is always the target
' Date: 18/11/2015
'
'
' Diagram Script main function
'
sub OnDiagramScript()
' Get a reference to the current diagram
dim currentDiagram as EA.Diagram
set currentDiagram = Repository.GetCurrentDiagram()
if not currentDiagram is nothing then
' Get a reference to any selected connector/objects
dim selectedConnector as EA.Connector
set selectedConnector = currentDiagram.SelectedConnector
if not selectedConnector is nothing then
'correct the composition direction for a single composition
correctCompositionDirection selectedConnector
else
'correct the composition direction for all compositions in the diagram
dim diagramLink as EA.DiagramLink
for each diagramLink in currentDiagram.DiagramLinks
'get connector from diagram link
dim connector as EA.Connector
set connector = Repository.GetConnectorByID(diagramLink.ConnectorID)
'set composition source and target
correctCompositionDirection connector
next
end if
else
Session.Prompt "This script requires a diagram to be visible", promptOK
end if
end sub
OnDiagramScript
function correctCompositionDirection(relation)
if relation.Type = "Association" or _
relation.Type = "Aggregation" then
'check aggregationKind
if relation.SupplierEnd.Aggregation <> 0 _
and relation.ClientEnd.Aggregation = 0 then
'switch source and target
'switch ID's
dim tempID
tempID = relation.ClientID
relation.ClientID = relation.SupplierID
relation.SupplierID = tempID
'switch Ends
switchRelationEnds relation
'save relation
relation.Update
end if
end if
end function
-
Part 2 of the code
function switchRelationEnds (relation)
dim tempVar
tempvar = relation.ClientEnd.Aggregation
relation.ClientEnd.Aggregation = relation.SupplierEnd.Aggregation
relation.SupplierEnd.Aggregation = tempvar
tempvar = relation.ClientEnd.Alias
relation.ClientEnd.Alias = relation.SupplierEnd.Alias
relation.SupplierEnd.Alias = tempvar
tempvar = relation.ClientEnd.AllowDuplicates
relation.ClientEnd.AllowDuplicates = relation.SupplierEnd.AllowDuplicates
relation.SupplierEnd.AllowDuplicates = tempvar
tempvar = relation.ClientEnd.Cardinality
relation.ClientEnd.Cardinality = relation.SupplierEnd.Cardinality
relation.SupplierEnd.Cardinality = tempvar
tempvar = relation.ClientEnd.Constraint
relation.ClientEnd.Constraint = relation.SupplierEnd.Constraint
relation.SupplierEnd.Constraint = tempvar
tempvar = relation.ClientEnd.Containment
relation.ClientEnd.Containment = relation.SupplierEnd.Containment
relation.SupplierEnd.Containment = tempvar
tempvar = relation.ClientEnd.Derived
relation.ClientEnd.Derived = relation.SupplierEnd.Derived
relation.SupplierEnd.Derived = tempvar
tempvar = relation.ClientEnd.DerivedUnion
relation.ClientEnd.DerivedUnion = relation.SupplierEnd.DerivedUnion
relation.SupplierEnd.DerivedUnion = tempvar
tempvar = relation.ClientEnd.IsChangeable
relation.ClientEnd.IsChangeable = relation.SupplierEnd.IsChangeable
relation.SupplierEnd.IsChangeable = tempvar
tempvar = relation.ClientEnd.IsNavigable
relation.ClientEnd.IsNavigable = relation.SupplierEnd.IsNavigable
relation.SupplierEnd.IsNavigable = tempvar
tempvar = relation.ClientEnd.Navigable
relation.ClientEnd.Navigable = relation.SupplierEnd.Navigable
relation.SupplierEnd.Navigable = tempvar
tempvar = relation.ClientEnd.Ordering
relation.ClientEnd.Ordering = relation.SupplierEnd.Ordering
relation.SupplierEnd.Ordering = tempvar
tempvar = relation.ClientEnd.OwnedByClassifier
relation.ClientEnd.OwnedByClassifier = relation.SupplierEnd.OwnedByClassifier
relation.SupplierEnd.OwnedByClassifier = tempvar
tempvar = relation.ClientEnd.Qualifier
relation.ClientEnd.Qualifier = relation.SupplierEnd.Qualifier
relation.SupplierEnd.Qualifier = tempvar
tempvar = relation.ClientEnd.Role
relation.ClientEnd.Role = relation.SupplierEnd.Role
relation.SupplierEnd.Role = tempvar
tempvar = relation.ClientEnd.RoleNote
relation.ClientEnd.RoleNote = relation.SupplierEnd.RoleNote
relation.SupplierEnd.RoleNote = tempvar
tempvar = relation.ClientEnd.RoleType
relation.ClientEnd.RoleType = relation.SupplierEnd.RoleType
relation.SupplierEnd.RoleType = tempvar
tempvar = relation.ClientEnd.Stereotype
relation.ClientEnd.Stereotype = relation.SupplierEnd.Stereotype
relation.SupplierEnd.Stereotype = tempvar
tempvar = relation.ClientEnd.StereotypeEx
relation.ClientEnd.StereotypeEx = relation.SupplierEnd.StereotypeEx
relation.SupplierEnd.StereotypeEx = tempvar
' tempvar = relation.ClientEnd.TaggedValues
' relation.ClientEnd.TaggedValues = relation.SupplierEnd.TaggedValues
' relation.SupplierEnd.TaggedValues = tempvar
tempvar = relation.ClientEnd.Visibility
relation.ClientEnd.Visibility = relation.SupplierEnd.Visibility
relation.SupplierEnd.Visibility = tempvar
relation.ClientEnd.Update
relation.SupplierEnd.Update
end function
-
It is said that once the person that invented the USB plug will die, he will be laid to his grave, taken out and turned around (twice?).
With the introduction of Type-C connectors, USB beat Sparx in solving the problem though. And, whichever the cable, USB communication has always been bi-directional by default :).
-
... communication has always been bi-directional by default :).
The problem here is that connectors as per specification do not have source and target but 2..* connecorEnds. S/T are EA-specific because they are stored this way in their database and do not hide this. Somehow one gets used to it.
q.
-
That has been discussed long and broad here.
Is it odd of me to expect the diagram represent ownership like so? :
[Whole]<.><-1--------*->[Part]
I used Borland/CodeGear's ORM Framework named Bold Architecture, and there the "filled diamond" was placed on the whole-side.
In any case, since this is about "ownership" the Supplier end should (of course) be the Source, and in my EA version (12.1.1222) it is always drawing the connector (correctly) from Source to Target.
Trying to execute the script I found out that you guys seems to be content with having the diamond on the Parts side. How odd you are! :)
[Whole]<-1--------*-<.>[Part]
// Rolf
[highlight][Edit][/highlight]: Fixed the navigability. BTW, in my own code generators I always interpret Unspecified as Navigable, and only by explicitly setting a role to Non-navigable I will suppress generating a member as Public.[/i]
-
Hi Rolf,
Check out:
http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1447148230/20#20
That may solve your problem.
Paolo
-
Hi Paolo,
Yes, by mistake I made the link non-navigable towards the whole (I'll fix that).
Normally I always make "ownership" links navigable in both directions.
And I agree, since the single reference (to Whole) is technically speaking embedded as a property on the Part side, there's no option left, such an association is by implication always navigable both ways.
It's another thing though to indicate in the model that one should not navigate in a certain direction, by making one role "non-navigable", but technically speaking you will of course always be able to navigate in both directions anyway.
// Rolf
-
Trying to execute the script I found out that you guys seems to be content with having the diamond on the Parts side. How odd you are! :)
Turns out the script has a completely wrong effect when executed on v12. In v12.1 is actually does what it is expected to do.
I guess there was a bug in the API in v12 that got fixed in v12.1
Geert