A scenario is the collaboration template code that handles a particular incoming business object or set of business object. This business object can represent an event (from a connector) or an access call (from an access client). You can think of a scenario as an event-handling method of your collaboration template class. Activity diagrams contain the code specifying how to handle the event.
You use scenarios to partition the business problem that a collaboration solves. You can group all the logic of the collaboration into a single scenario or you can create several scenarios, each dealing with one aspect of the problem. Grouping all collaboration logic into a single scenario is analogous to a program that contains all of its logic in a main() function, while using multiple scenarios is analogous to a program that is structured into separate functions.
You typically name scenarios according to the function they perform. When a collaboration contains multiple scenarios, each of which handles one type of business object, consider naming each scenario according to the business object that it handles. For example, if the collaboration handles one type of business object with different possible verbs, you can develop Create, Update, and Delete scenarios. If the collaboration handles different types of business objects, you can develop a scenario for each business object definition.
A scenario handles only one triggering flow (triggering event or triggering access call) with each execution. However, the same scenario can potentially handle a set of possible triggering flows. For example, the same scenario can handle a Create, Update, or Delete flow.
In general, when identical logic handles different types of business object, it is more efficient to use a single scenario for those business objects. This eliminates the need to test and debug multiple pieces of code.
Perform the following steps to create a new scenario:
The name is a string that can contain alphanumeric characters and underscores. If the scenario handles events with a particular verb, it can be useful to include the verb in the scenario name.
You assign a triggering event to a scenario in the Ports and Triggering Events table of the Ports and Triggering Events tab. For each scenario that you create, you must assign its triggering event. The triggering event is represented by a business object and a verb.
A collaboration's port definitions specify the types of business objects that the collaboration can send and receive. After defining the collaboration's ports and scenarios, you must specify:
In the Ports and Triggering Events tab, choose the row in the table that corresponds to the port name through which the triggering event enters and the business object name that represents the event.
The flow trigger is represented by the port business object and a verb (business-object.verb combinations). In the row of the port and business object for which you are defining flow triggers, you specify the flow trigger by choosing its verb.
Figure 25 illustrates these associations in a collaboration template whose port, From, supports business object type Widget. The Create scenario handles triggering event Widget.Create and the Delete scenario handles triggering event Widget.Delete.
Figure 25. Relationship of port, triggering event, and scenario
Specify the scenario for each flow trigger as follows:
After the scenario has been created, you can add scenario-specific variables in the Scenario Definitions dialog box (see Figure 26).
Figure 26. Scenario Definitions dialog box
Scenario variables are collaboration variables whose scope is all actions and links in a single scenario. (They are comparable to class variables in the Java programming language.) You can set scenario variables at any time during the collaboration template development process.
To add variables to the scenario definition, do the following:
Scenario variables do not persist automatically as part of the event flow context of a long-lived business process. If you want to use scenario variables within a long-lived business process collaboration, you must manually set the variable to null before the service call, and then re-initialize the variable after the service call completes. These tasks are done in the action node that makes the service call.
In the following example, a scenario variable called poolName is set to null in the action node before the service call takes place:
String poolName; poolName = null;
After the service call completes, poolName is re-initialized in the action node, as follows:
poolName = getConfigProperty("Pool_A");
You can use Process Designer Express to delete scenarios. Deletion of scenarios cannot be undone.
To delete a scenario definition, do the following: