Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: pirate_code on August 06, 2008, 10:27:09 am

Title: Setting element as Composite Element/NType=8
Post by: pirate_code on August 06, 2008, 10:27:09 am
Hey gang,

I am having some issues with creating an element that is a Composite Element (e.g. right click -> Advanced... -> Make Composite).  We are doing this on t_object/Object_Type='Component' and t_diagram/Diagram_type='CompositeStructure'

As far as I can tell, the only difference between elements (Components) that are composite or not is the field Ntype:
t_object/NType=0 --> Not Composite
t_object/NType=8 --> Composite

The child CompositeStructure diagram does exist with the Component's Object_ID set as the parent.  So this "should" work!

However, every now and then the interface forgets that an element is a composite, and we have to right click -> Advanced -> set to not composite; then re-set as composite and it works fine.  The same behavior exists when doing direct DB creation of these elements.

Any ideas?  Is there anything else in the DB or interface that specifies an element as a Composite element?

Thanks!
Title: Re: Setting element as Composite Element/NType=8
Post by: «Midnight» on August 06, 2008, 10:42:06 am
Perhaps you need to reload a diagram, package or project. There are various methods to do so.
Title: Re: Setting element as Composite Element/NType=8
Post by: pirate_code on August 06, 2008, 11:39:08 am
Quote
Perhaps you need to reload a diagram, package or project. There are various methods to do so.

Sadly, reloading the package/diagram/etc. does not fix the behavior.

If you right click -> Advanced -> the "Composite" check mark is selected!  However, the component does not display the infinity symbol in the lower right corner, nor can you double-click on the component to drill down to its CompositeStructure diagram.

I have created two components on the same diagram using SQL inserts into the t_object, t_diagrams and t_diagramobjects tables.  I have "unset" and "reset" the composite element attribute using EA on 1540 and the infinity shows up properly.  However, on object_id = 1541, I have not.  It shows up as composite under Advanced... but not in the actual diagram.

t_object for 1540 & 1541:
1540      Component      0      1.2.1.2 Test Fn      NULL      NULL      1.0      NULL      73      NULL      8      1      0      NULL      -1      0      -1      0      -1      2008-08-05 18:28:26.093      2008-08-05 18:29:21.000      Proposed      0      0      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      <none>      NULL      NULL      NULL      1.0      Public      NULL      NULL      0      {0B4F0E91-982A-457D-8E29-CD12C713C622}      565      NULL      NULL      0      0      0      0      0      NULL      NULL      NULL      NULL      NULL      NULL
1541      Component      0      1.2.1.3 Test Fn 2      NULL      NULL      1.0      NULL      73      NULL      8      1      0      NULL      -1      0      -1      0      -1      2008-08-05 18:30:07.217      2008-08-05 18:30:07.217      Proposed      0      0      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      NULL      <none>      NULL      NULL      NULL      1.0      Public      NULL      NULL      0      {DC10FEF9-38F9-4778-ADA8-AE02F12E33B7}      565      NULL      NULL      0      0      0      0      0      NULL      NULL      NULL      NULL      NULL      NULL

t_diagramobjects for 1540 & 1541:
54      1540      -170      280      400      -240      2      DUID=3FEEAB74;      6448
54      1541      -170      60      180      -240      1      DUID=47AB4AFE;      6449

t_diagram:
54      73      565      CompositeStructure      1.2.1 FnParent      1.0      user      0      NULL      NULL      1      1      1      P      2500      2500      100      2007-01-18 20:51:10.000      2008-08-05 18:30:31.000      NULL      1      1      1      HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=161;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=0;FormName=;      0      {29032DA5-12CE-4025-9955-19FEFC2C348E}      NULL      locked=false;orientation=0;width=0;inbar=false;names=false;color=0;bold=false;fcol=0;;cls=0;      ExcludeRTF=0;DocAll=0;HideQuals=0;AttPkg=1;ShowTests=0;ShowMaint=0;SuppressFOC=1;MatrixActive=0;SwimlanesActive=1;MatrixLineWidth=1;MatrixLocked=0;TConnectorNotation=UML 2.1;TExplicitNavigability=0;AdvancedElementProps=1;AdvancedFeatureProps=1;AdvancedConnectorProps=1;ProfileData=;MDGDgm=;STBLDgm=;ShowNotes=0;VisibleAttributeDetail=0;ShowOpRetType=1;SuppressBrackets=0;SuppConnectorLabels=0;PrintPageHeadFoot=0;ShowAsList=0;

Thanks for any assistance :-)
Title: Re: Setting element as Composite Element/NType=8
Post by: KP on August 06, 2008, 12:33:57 pm
Quote
As far as I can tell, the only difference between elements (Components) that are composite or not is the field Ntype:
t_object/NType=0 --> Not Composite
t_object/NType=8 --> Composite
There will also be a new record in the t_xref table (t_xref.Name='DefaultDiagram') which has the component's GUID in the t_xref.Client field and the diagram's GUID in the t_xref.Supplier field.
Title: Re: Setting element as Composite Element/NType=8
Post by: «Midnight» on August 06, 2008, 09:50:10 pm
So it seems like EA sees the indicator and starts the rendition process. If there is no 'inner' diagram to construct then EA stops the process and does not consider, or at least does not create a visual indication, that the element is 'really' composite.

Nothing unexpected here. I was going to ask whether you'd actually created the appropriate 'child' diagram and linked it up - from the child side. The cross reference is actually the key - though I'd forgotten, so would not have given you the best hint - to getting the whole thing working.

David
Title: Re: Setting element as Composite Element/NType=8
Post by: pirate_code on August 07, 2008, 08:31:16 am
Quote
So it seems like EA sees the indicator and starts the rendition process. If there is no 'inner' diagram to construct then EA stops the process and does not consider, or at least does not create a visual indication, that the element is 'really' composite.
Yes, the child diagram (CompositeStructure) is created and has its parent set to the newly created component.

KP was correct, the entry in the t_xref table did the trick.  So, in sum:

-> t_object/component
-> t_diagram/CompositeStructure diagram with ParentID set as @@Identity of the new component
-> t_diagramobjects/ParentDiagramID and ObjectID
-> t_xref/ComponentGUID and DiagramGUID

Bingo!  Works like a champ.  Thanks all.
Title: Re: Setting element as Composite Element/NType=8
Post by: KP on August 07, 2008, 09:11:23 am
For the record, can I just add a warning: the above applies to Components. Other object types do different things (e.g. Activities set t_object.PDATA1 to the DiagramID of the linked diagram) and I suspect this will remain undocumented and we reserve the right to change the representation, etc etc...

:)
Title: Re: Setting element as Composite Element/NType=8
Post by: «Midnight» on August 07, 2008, 09:52:23 am
Ouch.

Sorry, please allow me to rephrase that.

OUCH!
Title: Re: Setting element as Composite Element/NType=8
Post by: KP on August 07, 2008, 10:06:46 am
Quote
OUCH!
Agreed, but it's the price we pay for not wanting to change the schema. I think the solution here is to provide an Element.MakeComposite() method in automation, then these particular innards would be hidden. I have no idea if/when this might happen.see below
Title: Re: Setting element as Composite Element/NType=8
Post by: «Midnight» on August 07, 2008, 08:00:27 pm
Well, I'm on record - enough that it's a broken record by this time - regarding the need to update the schema.

I'm also on record that the pain involved grows the longer we wait. We might soon - perhaps already - be beyond the point where a change is tenable. Talk about being in a vice...
Title: Re: Setting element as Composite Element/NType=8
Post by: mrf on August 08, 2008, 08:57:34 am
I am currently working on adding a read/write IsComposite property for the Element interface. No confirmation yet as to when it will appear in EA as it has to go through the usual review and testing process. It will however abstract all the steps highlighted in this post into one variable assignment.
Title: Re: Setting element as Composite Element/NType=8
Post by: «Midnight» on August 08, 2008, 09:18:23 pm
Thank you Michael!

I will of course be appropriately overjoyed when this arrives. Just try to get it done before the year end. Here in the Frozen North it is a but cold to dance naked in the streets in mid-Winter.

David
Title: Happy Birthday... IsComposite
Post by: Paolo F Cantoni on August 05, 2009, 02:17:31 pm
Quote
I am currently working on adding a read/write IsComposite property for the Element interface. No confirmation yet as to when it will appear in EA as it has to go through the usual review and testing process. It will however abstract all the steps highlighted in this post into one variable assignment.
Hi Michael,

I just thought I'd wish your effort a happy birthday... (since the functionality isn't there as of interop.ea.dll 2.10.238.1) and the 8th Aug 2009 is a Saturday!  :o

No offense meant - since I'm SURE you aren't the reason the functionality hasn't surfaced yet...

It's just we've been needing this for YEARS...  :'(

Not holding breath,
Paolo
Title: Re: Setting element as Composite Element/NType=8
Post by: Gabriella on September 01, 2009, 07:16:45 pm
Hello.

Sorry, my English isn't perfect yet.  :)

I create an Activity diagram with the Java API. It contain an Activity element, which is Composite (NType=8), and I want to set him a child diagram.
I think, I must setting the t_object.PDATA1 field with the child diagram's DiagramID.
My question is, how can I setting this with the Java API?

Thank you, Gabriella.
Title: Re: Setting element as Composite Element/NType=8
Post by: Geert Bellekens on September 01, 2009, 07:20:59 pm
Element.MiscData
Check http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/element2.html

Geert
Title: Re: Setting element as Composite Element/NType=8
Post by: Gabriella on September 01, 2009, 07:45:34 pm
Yes, if the composite element's have a child diagram, MiscData(0) return with the child diagram's ID (PData1 field).
But MiscData is read only. How can I setting PData1 field?

Gabriella.
Title: Re: Setting element as Composite Element/NType=8
Post by: Geert Bellekens on September 01, 2009, 07:56:12 pm
Oh, I didn't see the "read-only" part.
In that case you can either wait for Sparx to finish their setComposite() operation on Element, or get your hands dirty (really dirty!) and change the field in the database yourself.

Geert
Title: Re: Setting element as Composite Element/NType=8
Post by: Gabriella on September 01, 2009, 08:22:58 pm
I haven't time wait for the setComposite() operation, I must make this at the moment.  ;)

Maybe you know that, how can I write the t_xref table with the Java?
Perhaps in this table I can setting a default diagram to the element.

Thank you: Gabriella.  :)
Title: Re: Setting element as Composite Element/NType=8
Post by: Geert Bellekens on September 01, 2009, 08:48:39 pm
Just connect to the database and launch an update query.
You should find plenty of examples on the internet.

Geert
Title: Re: Setting element as Composite Element/NType=8
Post by: Gabriella on September 01, 2009, 09:29:20 pm
Okay, thanks all! :)
Title: Re: Setting element as Composite Element/NType=8
Post by: Sascha Zinflou on June 22, 2010, 03:47:04 am
Instead of accessing the database via jdbc and getting hurt asking your db admin, I would suggest to use the Repository.Execute-Method with the desired SQL-Statement.

And, of course, I would apreciate very much if there was an enhancement to the API. As one should not manipulate the database directly, it is not comfortable to be forced to do that.
Title: Re: Setting element as Composite Element/NType=8
Post by: André Olivera on April 29, 2011, 06:54:00 pm
Hi!

What did you put in t_xref.XrefID??

How can I generate a new GUID and use it in this field?

Thanks!

André.

[edit] I used the C# function system.guid.NewGuid().ToString() and works.. but it is not dangerous?
Im afraid because the guid always must be unique.
Title: Re: Setting element as Composite Element/NType=8
Post by: Geert Bellekens on April 29, 2011, 07:46:24 pm
André,

With the function you are using you have about a 1/(3*10^38) chance to have a collision  :D

Geert