Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: brunovdb on May 15, 2013, 09:44:19 pm
-
I'm trying to create a new element that has the BPMN 2.0 Gateway stereotype.
The code I use to try this out goes as follows:
if (repository.IsTechnologyLoaded("BPMN2.0"))
{
Package model = (Package)repository.Models.AddNew("new model", "");
if (model.Update())
{
Package view = (Package)model.Packages.AddNew("new view", "");
if (view.Update())
{
Element element = (Element)view.Elements.AddNew("new decision", "Decision");
element.Stereotype = "Gateway";
if (element.Update())
{
if (element.SynchTaggedValues("BPMN2.0", "Gateway"))
{
element.Refresh();
}
}
}
}
}
The the SynchTaggedValues fails (returns false) and the resulting element does not contain any of the BPMN 2.0 Gateway specific properties.
Any suggestions on how to get this right?
-
I tried it here with V10. No problem. Which version do you use?
q.
-
Hello q,
The about box for EA gives me the following details:
- Program Version: 10.0.1007
- Database version: 4.01
- Registration details: Registered Enterprise Architect (Corporate Edition)
The version of the Interop.EA.dll is 2.10.238.1.
For what it's worth, I am calling the code from an add-in in EA.
Bruno
-
I have the same version. For the test I used a stand-alone program, but that does not make a difference. You probably should contact Sparx support.
q.
[edit] The only way it fails is when the MDG is turned off...
-
I think the most likely cause for failure would be having multiple BPMN profiles enabled.
However, the solution is easy.
Replace
Element element = (Element)view.Elements.AddNew("new decision", "Decision");
element.Stereotype = "Gateway";
if (element.Update())
{
if (element.SynchTaggedValues("BPMN2.0", "Gateway"))
{
element.Refresh();
}
}with
Element element = (Element)view.Elements.AddNew("new decision", "BPMN2.0::Gateway");
element.Update();
-
That sorted it out, thanks a lot!
Bruno
-
I realise I'm a bit late into this discussion, and thanks Simon for the answer to my question: I was stuck on the basic adding of a new BPMN element.
It seems odd that we need to create a new element of type 'BPMN20.::Gateway', rather than one of type 'BPMN2.0::Decision' with a stereotype="Gateway", which is what I was expecting.
It seems that this MDG has effectively defined some new "types" rather than stereotypes of existing ones.
My question is therefore where are these new types listed? The BPMN help explains very well what they are from the user's point of view e.g"Data Object", "End Event" etc, but is there somewhere where we can find the new type names which the API understands ? For example, do we:
addNew("something","BPMN2.0::Data Object") or
addnew("something","BPMN2.0::DataObject") etc
Also, is it just me who gets confused about what's a type, what's a stereotype, and what one of these new 'special types', which look like type+stereotype in the database, but which EA treats like first-class types when listing available types ? Are there some rules here which might merit a bit more explanation ?