Book a Demo

Author Topic: Adding new BPMN element using Java API  (Read 2920 times)

KG

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • looking forward to the crystal sea
    • View Profile
Adding new BPMN element using Java API
« on: October 24, 2008, 09:52:19 pm »
G'day eh!;

I am able to create new elements using the API for EA 831 except when i attempt to create something from another "tool palette" or tehcnology add in such as BPMN.
Alternately, is there a way that I can alter the representation or metaType of an element afterit has been added to  a collection?

Many thx in advance,


  

KG

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • looking forward to the crystal sea
    • View Profile
Re: Adding new BPMN element using Java API
« Reply #1 on: October 27, 2008, 10:33:03 pm »
Well;
I tried a few things based on a scan of the forum - put some to the puzzle together taking a look at the EA Use Guide on the sparx site.
I have resolved some of this problem by using a fully qualified stereotpye in the AddNew() and trapping off any execptions
that a first time call to CustomCommand appears to have and thinks worked. Almost; maybe; sometimes.

The problem came up when two stereotypes of the same name exists in the project load. As shown in the code example using a qualifier in the BOTh
the stereotype of the element and in the second argument to AddNew() works after a fashion - I now have a fully qualifed stereotype in the diagram.

An off-line discussion with Midnight leads me to believe the rest of the issues are related to setting of tagged values.


Code sample
try {
            Collection<org.sparx.Element> elements = composite.GetElements();
            org.sparx.Element modelElement = elements.AddNew(name, "BPMN::Activity");
            if(stereotype != null){
                  modelElement.SetStereotype(stereotype);
                  _repository.CustomCommand("Repository", "SynchProfile", "BPMN::Activity");
            }
            modelElement.Update();
            elements.Refresh();
      } catch (RuntimeException e) {
            _repository.CustomCommand("Repository", "SynchProfile", "BPMN::Activity");

      }
      
When I get out from under this deadline I test out the use of unqualfied "Activity" in the stereotype set.