Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Shaun Yandle on February 13, 2013, 07:47:50 am

Title: How to create MDG elements via API?
Post by: Shaun Yandle on February 13, 2013, 07:47:50 am
Using EA v10 b1004. Trying to create BPMN2 elements via Java batch application to provide an import from external data/relationship sources.

I can do this via UI, but unable to figure out what/how to get the same result via API. UML Activity is close but not sufficient.

Already doing the base work of obtaining the Collection<Elements>.AddNew(name,type?)
No stereotypes show when manually created.

Any advice is appreciated!
Title: Re: How to create MDG elements via API?
Post by: qwerty on February 13, 2013, 10:05:28 am
You need to supply the MDG identifier. E.g.
Code: [Select]
AddNew ("name", "BPMN2.0::Activity")
q.
Title: Re: How to create MDG elements via API?
Post by: Danny F on February 13, 2013, 07:40:02 pm
I've got this working with elements - but not with packages

When I create a package, referring to the [profile]::[type] I get no stereotype in the created package.

This profile is not created by me (and I haven't done that - yet), can it be a missing thingy in the profile ?

gr
Title: Re: How to create MDG elements via API?
Post by: qwerty on February 13, 2013, 11:13:17 pm
No idea. Either you wait a day for a Sparxian to reply or contact their support.

Is it a certain package out of the BPMN2 profile from Sparx?

q.
Title: Re: How to create MDG elements via API?
Post by: Danny F on February 13, 2013, 11:26:59 pm
No - it's a home made profile by one of my colleagues.

Problem is we're both beginners in EA MDG/automatisation
Great product but ....  ;)
Title: Re: How to create MDG elements via API?
Post by: qwerty on February 14, 2013, 12:09:50 am
But you can create the package manually using that profile?

q.
Title: Re: How to create MDG elements via API?
Post by: Shaun Yandle on February 21, 2013, 08:02:33 am
Took me a bit of more trial-and-error, but discovered that you have to use the stereotype defined in the MDG xml (and that shows in Project Browser).  So more of [MDG-ID]::[MDG-Stereotype]. For example, use BPMN2.0::StartEvent

Basically, do not set the stereotype field (I have a utility routine that does the createElement(name, type, stereotype) ).

Thanks!
Title: Re: How to create MDG elements via API?
Post by: Danny F on February 21, 2013, 05:12:17 pm
Yep use [profile::type]  BUT it doesn't seem to work for a package
Works for EA.Element, not for EA.Package
- in my case anyway

Querty asked if the package can be created thru the MDG ?
I don't know - it is not in the toolbox.
The MDG package is there only to be used by the add-in; the user doesn't manually create such packages

Title: Re: How to create MDG elements via API?
Post by: qwerty on February 21, 2013, 10:53:19 pm
Quote
Querty asked if the package can be created thru the MDG ?
I don't know - it is not in the toolbox.
The MDG package is there only to be used by the add-in; the user doesn't manually create such packages

For testing purpose you should put it into a toolbox so you'll be sure it is created correctly. If it doesn't create manually the API won't do it anyway.

Probably you should think of having the package in a toolbox permanently for maintenance purpose.

q.