Book a Demo

Author Topic: Not able to create CompositeDiagram via Automation  (Read 6172 times)

Sascha Zinflou

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Not able to create CompositeDiagram via Automation
« on: June 12, 2010, 07:51:38 pm »
I need to set a CompositeDiagram to an Element via Automation and I am using EA 7.5.850, and I it does not work ;-)

What I am able to reach is:
 - create the diagram as a subnode in the project explorer
 - leaving the element in a state, in which selecting it in any diagram where it appears, and by choosing Context Menu -> Advanced -> MakeComposite results in the desired behaviour: I can navigate from one diagram via the composite object to the more detailed diagram.

What I am not able to reach uo to now is:
 - Creating the composite element with the correct behaviour from the automation interface. The element created has neither the little "infinity-like" symbol showing it is composite, nor can I navigate to the associated model by clicking it.

What I tried up to now is:

Code: [Select]
               

//Creating the element in some package
EA.Element eaElement = (EA.Element)eaParentPackage.Elements.AddNew("someName","Activity");
eaElement.Stereotype = "BusinessProcess";
eaElement.Update();
eaParent.Elements.Refresh();

//trying making it composite
tryToMakeCompositeBefore();

//Creating the Subdiagram
EA.Diagram eaDiagram = (EA.Diagram)eaElement.Diagrams.AddNew("someName", "Analysis");
eaDiagram.Update();
eaElement.Diagrams.Refresh();
eaElement.Update();

//trying making it composite
tryToMakeCompositeAfter();


What I tried as well in tryToMakeCompositeBefore as in tryToMakeCompositeAfter, was

Code: [Select]
eaElement.Subtype = 8;
eaElement.TaggedValues.AddNew("diagram", "EAID_" + eaDiagram.DiagramGUID.Substring(1,eaDiagram.DiagramGUID.Length-2)); eaElement.TaggedValues.Refresh();

I tried also to use only one of the rows. The idea to add the tagged value came from analyzing the difference between XML-Exports between a working and a non working version.

Any help would be appreciated, as well as uncommented sample code creating working composite elements in any other context.

Sascha

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #1 on: June 13, 2010, 04:00:33 pm »
Hi Sascha,

The "secret sauce" you are looking for is documented in: Setting element as Composite Element/NType=8 which can be found using the [Search] button between [Help] and [My Center] above.

You should read the whole topic for a more complete picture...

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

Sascha Zinflou

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #2 on: June 15, 2010, 12:21:07 am »
Hi Paolo,

thank you very much, as well for the link as for the hint using the Search-Button. I used the small search bar on the right before posting and it is just now that I learned: that one does not really search the entire forum :-(

I will give a short feedback again, when I have read the thread and tried the solution proposed.

CU
Sascha

Sascha Zinflou

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #3 on: June 22, 2010, 03:43:39 am »
Hi Paolo,

I am coming back to the problem just today, and with the thread you mentioned it works.

Finally a                                
_repository.Execute("UPDATE t_object SET PDATA1 = '" + eaDiagram.DiagramID + "' where Object_ID = " + eaElement.ElementID); helped.

I will just have to think on how I will get this one through a code review ;-)

So thanks again for your help.

Take care
Sascha

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #4 on: July 02, 2010, 11:01:32 pm »
Hi Sasha,

I am currently working on the same "wish". I am trying to set up composits by an addin.

Unfortunately the repository.execute (see C# snippet below) does not bring the required result  :(

string sqlStr = "UPDATE t_object SET PDATA1 = '" + dgId + "' where Object_ID = " + element.ElementID.ToString();
                repository.Execute(sqlStr);

just won't work..
Is there something I am missing?

Regards
Rainer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Not able to create CompositeDiagram via Automa
« Reply #5 on: July 02, 2010, 11:08:42 pm »
Rainer,

Have you checked the dbError.txt?
If there is something wrong with the query then it might have reported it there.
Otherwise I guess it just didn't find the record you are trying to update.


Geert

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #6 on: July 03, 2010, 01:49:51 pm »
Hi Geert,

I don't get a db error. The sql seems to be excecuted ok.
I tried different sql text for example putting the element Id in quotes. There I got a db error.

Regards
Rainer

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Not able to create CompositeDiagram via Automa
« Reply #7 on: July 05, 2010, 05:43:23 pm »
Rainer,

If I remember correctly the database update was only part of the solution.
Have you also done the the rest?

Geert

RainerQ

  • EA User
  • **
  • Posts: 122
  • Karma: +1/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #8 on: July 05, 2010, 09:25:18 pm »
Hi Geert,

this morning I received  a response from sparx concerning the issue including a vb sample hot to handle the subject. It seems to work ok ..so far..

By the way.. yes there was more to the solution which I was missing to do ;-)

Thanks for responding
Rainer

peuhhhh

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: Not able to create CompositeDiagram via Automa
« Reply #9 on: July 06, 2010, 12:35:07 am »
Hello,
Could you please post an example how it is working ?

regards,