Book a Demo

Author Topic: Attached diagrams vs Composite Diagrams  (Read 5609 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Attached diagrams vs Composite Diagrams
« on: September 06, 2018, 12:57:04 pm »
Our diagrammer Add-In was created a LONG time ago when it wasn't possible to create attached diagrams through the API.  We've left it alone, until now, when we've discovered that when it creates the attached diagram for an InteractionFragment our existing process will set the type of the fragment to "strict", regardless of what it started as.  This is because the NType field is incorrectly overloaded by the architecture.

Notice I said "attached diagram" above.  In our repository for every modelling vertex, we create a Neighborhood diagram.  We store it as a child of the vertex.  It's not strictly a Composite Diagram, but we want the UI effect of double-clicking on the vertex in a diagram opening up the attached Neighborhood diagram.  It's our understanding that the only way to attach such a diagram to the vertex is to make the vertex composite and the set the composite diagram.  Can anyone confirm that this is the correct understanding of how to attach such a diagram to a vertex?

As I read the current Help System, I have to make the element composite by setting the IsComposite property and then attaching the diagram via the SetCompositeDiagram method.  I can use the CompositeDiagram property to determine if the Composite vertex already has an attached diagram.

Do I understand it correctly?

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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attached diagrams vs Composite Diagrams
« Reply #1 on: September 06, 2018, 04:08:16 pm »
As I read the current Help System, I have to make the element composite by setting the IsComposite property and then attaching the diagram via the SetCompositeDiagram method.  I can use the CompositeDiagram property to determine if the Composite vertex already has an attached diagram.

Do I understand it correctly?

I think so, but I also remember it not working 100% at some point.
The composite diagram construction is not the same for all types of Elements and it may very well be that it only worked for a subset of elements.

Anyway, this is code I use in one of my scripts. It works but it doesn't deserve a beauty price :-\

Code: [Select]
'set the given diagram as composite diagram for this element
function setCompositeDiagram (element, diagram)
if not diagram is nothing then
'Tell EA this element is composite
dim objectQuery
objectQuery = "update t_object set NType = 8 where Object_ID = " & element.ElementID
Repository.Execute objectQuery
if element.Type = "Object" then
'Tell EA which diagram is the composite diagram
dim xrefQuery
xrefquery = "insert into t_xref (XrefID, Name, Type, Visibility, Partition, Client, Supplier) values ('"&CreateGuid&"', 'DefaultDiagram', 'element property', 'Public', '0', '"& element.ElementGUID & "', '"& diagram.DiagramGUID &"')"
Repository.Execute xrefquery
elseif element.Type = "Activity" then
'for activities we need to update PDATA1 with the diagramID
dim updatequery
updatequery = "update t_object set PDATA1 = "& diagram.DiagramID & " where Object_ID = " & element.ElementID
Repository.Execute updatequery
end if
end if
end function

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Attached diagrams vs Composite Diagrams
« Reply #2 on: September 06, 2018, 04:13:43 pm »
Sorry, Geert,

I didn't make myself clear enough.  I already have code that's similar to yours (and it also won't get a beauty prize  ;)).

My point is that it is now breaking down.  The API NOW provides a, hopefully, more correct method to do this.  Is my understanding of the API elements correct?

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

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Attached diagrams vs Composite Diagrams
« Reply #3 on: September 06, 2018, 04:42:18 pm »
Paolo,

I'm pretty sure I wrote that piece of code after I tried using the API methods and they (for some reason) failed me.

But since that is a couple of years ago, the API might have been improved in the mean time.

Can you specify how/where exactly your current code it causing issues? We might be facing the same problem.

Geert

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Attached diagrams vs Composite Diagrams
« Reply #4 on: September 06, 2018, 05:20:44 pm »
Paolo,

I'm pretty sure I wrote that piece of code after I tried using the API methods and they (for some reason) failed me.

But since that is a couple of years ago, the API might have been improved in the meantime.

Can you specify how/where exactly your current code it causing issues? We might be facing the same problem.

Geert
My problem is as outlined in the OP.  I set the NType explicitly to 8.  However, this doesn't work for InteractionFragments (as one example).  I'm hoping that a Sparxian can say:  Ntype=8 for All element types except for InteracationFragments, xxxx and yyy.  That way I can conditionally set NType to 8 as appropriate.  However, if the API now works, then I shouldn't need to worry.  Hopefully, the new mechanism doesn't even set NType, just uses the t_xref entries to manage everything.

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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attached diagrams vs Composite Diagrams
« Reply #5 on: September 06, 2018, 07:06:50 pm »
Maybe. Or not. That's the question. The help says
Quote
SetCompositeDiagram()
with no paramters. But then
Quote
Parameters:
GUID: String - the GUID of the composite diagram; a blank GUID will remove the link to the composite diagram
So, what??

q.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Attached diagrams vs Composite Diagrams
« Reply #6 on: May 11, 2022, 05:54:02 pm »
More than 3 years the help is still not fixed.

q.