Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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!
-
Perhaps you need to reload a diagram, package or project. There are various methods to do so.
-
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 :-)
-
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.
-
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
-
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.
-
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...
:)
-
Ouch.
Sorry, please allow me to rephrase that.
OUCH!
-
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
-
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...
-
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.
-
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
-
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
-
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.
-
Element.MiscData
Check http://www.sparxsystems.com/uml_tool_guide/sdk_for_enterprise_architect/element2.html
Geert
-
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.
-
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
-
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. :)
-
Just connect to the database and launch an update query.
You should find plenty of examples on the internet.
Geert
-
Okay, thanks all! :)
-
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.
-
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.
-
André,
With the function you are using you have about a 1/(3*10^38) chance to have a collision :D
Geert