Setting The Trigger for a Transition Through the API
Overview
This tip is for anyone that writes their own helpers for Rhapsody and is specifically about setting the event that triggers a transition on a statechart.
Setting the Trigger for a Transition
The Rhapsody API has a single function to do this, but it takes a string: IRPTransition.setItsTrigger(String) which can be problemmatic, for example take the following example:

If we call setItsTrigger ("ev1") in the API, which event will be used ? There are three events with this name and they are all in different packages. The simple answer is 'the first one Rhapsody finds'.
Clearly this is not a stable solution. To understand how to build a stable solution, we must understand how Rhapsody decides which event to use. It uses the following tests - in order.
1. If the owning classifier (in this case the class called Cls) has an event reception with that name - then that is the event reception that will be used as the trigger for the transition.
2. If the owning package has an event with that name then a new reception of that event is added to the classifier and that event reception is used on the transition.
3. Rhapsody searches the model for an event with that name and uses the first one it finds. Again it adds an event reception and a trigger.
Using a Specific Event
The string argument in setItsTrigger can be the full path to an event instead of just the name, for example:
transition.setItsTrigger("Pkg3::ev1");
would add a reception of the event ev1 from package Pkg3 to the classifier and then use that event recption as the trigger. Whilst this would seem to be the solution to the problem, there is a caveat. If the classifier already has a reception of the named event (in this case ev1) from anywhere else, then the path you specify is ignored and the already existing event reception is used as a trigger.
If you want to be specific about which event triggers a transition then it is the event reception in the owning classifier that is the key. You could, for example, check if the event reception exists and if not then create it before calling setTrigger with the name (or instead call setTrigger with the full path and let Rhapsody create the reception). If a reception does exist then you can check it to see if it is the correct event - if not then simply remap it before calling setTrigger (Receptions have a setEvent function).
Hopefully that clears up how the setItsTrigger function works !