Refactoring Activities into a Sub-Process
You can create a new call sub-process activity and sub-process by extracting existing objects.
Procedure
- Select the objects that you want to put in the sub-process. For example:
- Select all three tasks.
- Right-click and select Refactor > Extract into New Sub-Process.
- Because the data fields and participants are only referenced in this activity (and not used by any other activities), the following message is displayed:
- Complete the dialog as follows:
-
Click
Finish. The objects that you selected are copied to the new sub-process and the selected objects are replaced with a task that calls the call sub-process.
If you chose to create formal parameters for the data fields, you can see them in the Project Explorer, under the sub-process:
In addition, if you click the task in the parent process that calls the sub-process and go to the Properties view, you can see the mappings that have been created between data fields and formal parameters of the parent process and the formal parameters created in the sub-process. For example:
Notes on Refactoring Objects into Sub-Processes:
- Formal parameters in the parent process are created as formal parameters in the sub-process. They are mapped according to their mode as defined in the process API.
- If a data field is referenced only in the selection that you are refactoring, you have the option of moving or copying it. Data fields that are copied into the sub-process are created as formal parameters and mapped. Data fields that are moved into the sub-process are created as data fields. By default, data fields are moved. In order to copy them as formal parameters, you must uncheck the selection boxes on the dialog.
- If a data field is referenced in one or more of the tasks you select for refactoring but is also referenced elsewhere, it is automatically copied into the sub-process as a formal parameter.
- A mapping is created between data fields and formal parameters of the sub-process and any corresponding formal parameters that are created in the sub-process. You can view this mapping by selecting the task that calls the sub-process and clicking the Map To Sub-Process and Map From Sub-Process tabs in the Properties view.
Changes in Process Logic:
When refactoring objects into a call sub-process, you can potentially change the logic of the process flow.
Consider the following process:
In this process, flow proceeds from User Task 1 to the gateway without necessarily waiting for Task A to finish. If User Task 1 and Task A are refactored into a sub-process, an end event is inserted into the sub-process, effectively synchronizing the flow. TIBCO Business Studio prompts you to confirm this change to the process: