Author Topic: Automatically create aggregation relationships?  (Read 617 times)

michielper

  • EA User
  • **
  • Posts: 120
  • Karma: +1/-0
    • View Profile
Automatically create aggregation relationships?
« on: October 08, 2018, 09:15:51 pm »
I have a situation here where there are many diagrams with nested elements without explicit relationships. The language used is Archimate and nesting has no meaning in Archimate. The meaning that is implicitly assumed by visual nesting comes closest to Aggregation. So in order to make the diagrams into meaningful Archimate diagrams, explicit aggregation relationships must be created wherever a hierarchy (nesting) exists. I suppose it should be possible to to this automatically, via a script. Has anyone attempted this?

Thanks!
Michiel

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9392
  • Karma: +258/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Automatically create aggregation relationships?
« Reply #1 on: October 08, 2018, 09:43:34 pm »
I was just writing a script to just exactly that  :o

Code: [Select]
function linkToParent(prElement, processDictionary)
'get the ref
dim parentRef
parentRef = ""
'trim off the last .xx
dim dotLoc
dotLoc = InStrRev (prElement.Alias,".")
if dotLoc > 1 then
parentRef = left(prElement.Alias, dotLoc -1)
end if
if len(parentRef) > 0 then
'get the parent
dim parentProcess as EA.Element
set parentProcess = nothing
if processDictionary.Exists(parentRef) then
set parentProcess = processDictionary(parentRef)
end if
if not parentProcess is nothing then
'check if not already present
dim existingCompositions
dim sqlGetExistingCompositions
sqlGetExistingCompositions = "select c.Connector_ID from t_connector c     " & _
" where c.Stereotype = 'ArchiMate_Composition' " & _
" and c.End_Object_ID = " & parentProcess.ElementID &  _
" and c.Start_Object_ID = " & prElement.ElementID
set existingCompositions = getConnectorsFromQuery(sqlGetExistingCompositions)
if existingCompositions.Count = 0 then
'create Archimate composition to parent
dim composition as EA.Connector
set composition = prElement.Connectors.AddNew("","Archimate2::ArchiMate_Composition")
composition.SupplierID = parentProcess.ElementID
composition.SupplierEnd.Aggregation = 2 'Composite
'set direction
composition.Direction = "Source -> Destination"
composition.ClientEnd.Navigable = "Unspecified"
composition.ClientEnd.Update
composition.SupplierEnd.Navigable = "Navigable"
composition.SupplierEnd.Update
'save
composition.Update
end if
else
'report error
Repository.WriteOutput outPutName,now() & " Could not find parent process with reference: " & parentRef, prElement.ElementID
end if
end if
end function
Weird thing is that you have to model it with the part as source and the whole as target.
And there is something fishy going on with the direction as well. If I don't specify anything i get an arrow pointing to the part, and Direction "Destination -> Source" ???
The code above does the same thing compared to adding one manually.

Geert

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1301
  • Karma: +103/-75
    • View Profile
Re: Automatically create aggregation relationships?
« Reply #2 on: October 09, 2018, 07:14:05 am »
Weird thing is that you have to model it with the part as source and the whole as target.
And there is something fishy going on with the direction as well. If I don't specify anything i get an arrow pointing to the part, and Direction "Destination -> Source" ???
The code above does the same thing compared to adding one manually.

The ArchiMate direction is the reverse of the UML direction, so properly modelled connections look backwards in the traceability view.  Years ago I asked Sparx if they could just flip the ArchiMate shapescript but that idea seemed to fall on deaf ears.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6800
  • Karma: +142/-103
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Automatically create aggregation relationships?
« Reply #3 on: October 09, 2018, 11:17:57 am »
Weird thing is that you have to model it with the part as source and the whole as the target.
And there is something fishy going on with the direction as well. If I don't specify anything I get an arrow pointing to the part, and Direction "Destination -> Source" ???
The code above does the same thing compared to adding one manually.

The ArchiMate direction is the reverse of the UML direction, so properly modelled connections look backwards in the traceability view.  Years ago I asked Sparx if they could just flip the ArchiMate shapescript but that idea seemed to fall on deaf ears.
Indeed the ArchiMate "direction" is the reverse of the UML, as it also is with Specialization/Generalization.  However, I believe the ArchiMate directionality is more conceptually correct.  In both cases, the client and supplier items are at the "Correct" end of the relationship.  I'll have to check the direction in the traceability view since I don't use it much - preferring to use our Neighborhood diagrams.

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

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6786
  • Karma: +63/-6
    • View Profile
Re: Automatically create aggregation relationships?
« Reply #4 on: October 09, 2018, 01:51:11 pm »
The ArchiMate direction is the reverse of the UML direction, so properly modelled connections look backwards in the traceability view.  Years ago I asked Sparx if they could just flip the ArchiMate shapescript but that idea seemed to fall on deaf ears.
Alternatively, ears that have heard too many complaints already about changing anything like that.

If we just changed it, it would be reversed on all existing diagrams.
If we changed the way they were created, anyone using the API or querying the database would be unable to resolve them.
If we provided an option, the previous issue multiplies.

There are issues with keeping it that way too, but I'm not sure if they are worse.
Eve

support@sparxsystems.com

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1301
  • Karma: +103/-75
    • View Profile
Re: Automatically create aggregation relationships?
« Reply #5 on: October 10, 2018, 07:37:43 am »
Alternatively, ears that have heard too many complaints already about changing anything like that.

You shouldn't go listening to qwerty :-)