 | Level: Intermediate Marc Fasbinder (mfasbind@us.ibm.com), Consulting I/T Specialist, WebSphere Software Technical Sales,
IBM
28 Mar 2007 IBM® WebSphere® Business Modeler (hereafter called Modeler) is a powerful tool for business analysts to accurately model their unique business processes. When modeling a business process, you need to apply best practices, including using proper notation. A common mistake using notation is where a control link flows back in the model to a previous activity, which causes problems with both simulation and export to WS-BPEL. This article shows how to revise a process with a backwards flowing connector, to instead use a Loop. This technique lets you properly simulate the process, and export it to WS-BPEL. You should have basic knowledge of Modeler and WS-BPEL.
Introduction
WebSphere Business Modeler is a powerful tool that can help with many tasks including:
-
Modeling for documentation and compliance: Many times a process is not well documented. Some companies want to capture the process just for the sake of documentation, while others need to do so for regulatory reasons.
-
Modeling for redesign: Some companies want to take their current state (as-is) processes, and improve them. Modeler provides a powerful simulation engine to help in this area, along with both dynamic and static reports for defining a future state (to-be) process.
-
Modeling for execution: Some companies want to implement a business-driven development cycle, where a business analyst can build a model that is used to create useful artifacts for I/T. This model allows for faster development cycles, and ensures that the implemented process meets the business requirements.
Because Modeler is such a feature-rich, powerful tool, some functions require some education to use them to their fullest extent. In addition, a non-technical business analyst who uses the tool probably will not consider the requirements of the target runtime environment. For example, you wouldn’t expect business analysts to understand the WS-BPEL standard. Therefore the business analysts often create models that need to be cleaned up before they can be properly simulated and exported.
The solution is let the business analysts model the processes, and then transfer ownership of the model to the I/T staff to clean it up so it can be properly simulated and exported to WS-BPEL. This articles targets the IT professional who will clean up the model, although some more technical business analysts might also be interested in learning these techniques.
Loops are one of the most common areas where business analysts (hereafter referred to as analysts) use improper notation, for example:
- Some analysts connect one task back to a preceding task in the flow. This technique not allowed in the WS-BPEL standard. The process cannot be exported unless you correct the model.
- Some analysts use For Loops or Do-While Loops, which are not supported in WS-BPEL. The OASIS group that creates the WS-BPEL standard has only defined While Loops as a part of the language. Using other types of loops in the model would prevent the process from being exported.
- For a While Loop to work when exported to BPEL, it needs to access data from the process, for which a repository must be used. Repositories are often a difficult concept for a non-technical analyst.
As a technical user of WebSphere Business Modeler, you get to the dirty work of cleaning up the model, regardless of the type of flaws.This article shows you how to properly model a While Loop that will work in simulations, as well as being exportable to WS-BPEL. For this scenario, we assume that the analyst already created a business process containing some of these common flaws. We’ll first look at an incorrect process, then fix it to add the correct looping structure. Finally, we’ll create a repository to correctly manage data flowing through the process.
Examining the process
So the analyst has created a simple process that you need to update, using Basic mode in Modeler. Set your Modeler to Basic mode as well. In our scenario, the original process looks like Figure 1.
The process diagram
Figure 1. The original process
The analyst wants to run the task named Repeat Task multiple times, until the Done? condition is true. This notation is fine for documentation purposes, but a WS-BPEL process cannot flow backwards to a previous activity. Clearly, we need a While Loop.
Also, since the process will run in WS-BPEL, data needs to flow into the first task. To make the process more reusable, it would be preferable to have data flowing out at the end. We need to make these updates as well.
Finally, as modeled by the analyst, the current process cannot be simulated. Repeat Task has two inputs, but as by default an AND operation is performed on them. However, only one of the two paths will ever flow into the task.
For simulation purposes, we’ll assume the Done? condition will flow to the Yes branch 80.0% of the time, and the No branch the other 20.0%, as Figure 1 shows. The analyst would provide these percentages as an estimate for how often the flow will take each branch.
This process may seem simple, but it illustrates how an analyst could construct something that will not simulate or export properly. It contains two of the three common flaws mentioned above.
The business item
The process contains a business item called Data, as Figure 2 shows. A business item represents something flowing between steps in the process, for example a paper document or an electronic request.
Figure 2. The business item
The comment for Repeat Task says that the task should run until the Status field is set to
Done. The analyst defined what needs to happen. As the technical resource, it is your job now to define how to make it happen.
Create an updated process model
In this section we’ll create a copy of the process model, and fix it so that it correctly models the analyst's intention, can be simulated, and conforms to the WS-BPEL standard.
Copy the process
If you do not have a version control system you should work on a copy of the business process so that you can refer back to the original. The best practice would be to use a source control system such as IBM Rational ClearCase.
- Close the editor for
Original Process by clicking on the X.
- Right-click on Original Process in the Project Tree and select Copy, as Figure 3 shows:
Figure 3. Copying the process
- Right-click the Processes folder and select Paste.
- Right-click Copy of Original Process and select Rename. Enter a new name such as
Loop Process.
- Right-click Loop Process and select Open to edit it, or double-click it.
Adding a While Loop
A While Loop repeats any of the tasks inside it until a condition is true. It checks the condition before running the tasks in the loop. This means that we can get rid of the decision in the process, along with the control connectors, since we’ll move Repeat Task inside the loop.
- Right-click the Done? decision, and select Delete.
- Right-click the connection from First Task to Repeat Task and select Delete.
Tip: If you click the business item rather than the link, you will only delete the business item. Be sure to click on the link itself, so that the process looks like Figure 4:
Figure 4. Loop Process with deleted decision and links
- From the palette on the left of the Process editor, click the icon for Create While Loop
, then click the drawing space to add it above Repeat Task. As an alternative, you can right-click on the drawing area and select New - While Loop to accomplish the same task. Your model should now look like Figure 5:
Figure 5. While loop added to the process
Moving the task into the loop
The next job is to move Repeat Task inside of the While Loop. The best way to accomplish this is through cut and paste.
- Right-click on Repeat Task and select Cut.
- Click on the + in While Loop to drill down into it. Alternatively, you can right-click on While Loop and select Edit.
Editing the While Loop
When a While Loop is first edited, the only item visible at first is the Start Node.
- Right-click on the drawing area and select Paste, which adds Repeat Task to the process diagram.
- Add a Stop Node after Repeat Task. In order to simulate properly, all processes, loops and subprocesses must end with a Stop Node.
- Click on Connections
and connect the Start Node to Repeat Task.
- Connect Repeat Task to the Stop Node.
- Click ESC to exit connect mode.
- Right-click the diagram area and select Auto-Layout Left to Right, as Figure 6 shows:
Figure 6. Inside the While Loop after editing
- Right-click the diagram area and select Root to return to the high level process, as Figure 7 shows. If you have multiple levels of loops and subprocesses, you can use Parent to move up one level, or Root to move up to the top level. Because this process has only one level, either option will work.
Figure 7. Navigate back to the parent process
Connect the While Loop to the other tasks
You can now connect the While Loop to the other tasks in the high level process:
- Connect First Task to While Loop.
- Connect While Loop to Last Task.
- Right-click on the diagram area and select Auto-Layout Left to Right, as Figure 8 shows:
Figure 8. While Loop connected
Now you’ve updated your process to use proper notation.
Adding the data flow to the process
The flow of data within the business process needs to be added to the diagram. This work might be done by a business analyst. However, it will often be a task for a technical resource to add this information into the model.
Adding a Repository
In Modeler, you store business items in a repository. When you export the process to WS-BPEL, it transforms it into a BPEL variable. We need to place the output from First Task into a repository so that it can be accessed from within While Loop:
- Click on the icon for a Local Repository
from the palette, and click below While Loop to add it to the process diagram.
- Click on the repository, wait a moment, then click again to select its name. Change the name to
Loop Data Store, and press Enter.
- Scroll down in the attributes pane if necessary, until you see Associated data, where you can specify what type of data is stored in the repository.
- Click browse and select the Data business item, as Figure 9 shows:
Figure 9. Associating data with the repository
- You need to save the Repository before connecting it. Press Ctrl-S or File - Save to store the model.
Connecting the Repository to the process
- Connect First Task to Loop Data Store, as in Figure 10:
Figure 10. Connecting First Task to Loop Data Store
Now the output Data from First Task flows into Loop Data Store, where it can be read from inside While Loop. When While Loop completes, the output data also flows into Loop Data Store. This means that Data needs to flow out of Loop Data Store and into Last Task.
- Connect Loop Data Store to Last Task, as in Figure 11:
Figure 11. The process fully connected
Tip: If you forgot to set the associated data for the repository, when you connect to your tasks it will use “String” as the default. If you then change the associated data for the repository, you have to go back and change the data on the connection as well. It’s much easier if you remember to associate the data when you first add the repository to your process.
Defining data flow in and out of the process
When a process starts, data can be passed to it. The process can also pass a result back, which helps make it a better candidate for reuse. Next we’ll define this data flow:
- Click the process background so that the process itself is selected.
- Click the Inputs tab.
- Click Add to create an input to the process.
- Click Browse and select the Data business item, as Figure 12 shows.
Tip: You may want to use the and controls to reduce the paper size of the drawing area. Make the drawing area as small as possible for easier editing and printing.
Figure 12. Setting up the process input data
- Repeat steps 1-4 using the Output tab to create an output for the process, and set its type to
Data.
Connecting process input and output to tasks
The
Data business item now flows into and out of the process. Next we need to wire First Task and Last Task to use the process input and output. We need the connections to the Start and Stop nodes for simulation, and the additional connections for the flow of data. You could simulation without these additional data connections, but the process would not properly export to WS-BPEL.
- Scroll all the way to the left side of the process.
- Click the
icon to enter Connection Mode.
- Click the vertical bar at the left edge of the process. The icon for the pointer changes when you reach the area you can click.
- Click First Task to complete the connection.
- When prompted, make sure Input Data and Create a new input are selected for the process, and click OK, as Figure 13 shows:
Figure 13. Prompt when connecting to First Task
- Repeat steps 3-5 to connect Last Task to the right edge of the process.
- Click Ctrl-S to save the process. Your process should now look like Figure 14:
Figure 14. High-level process fully connected
Advanced process editing
So far we’ve just worked in Basic mode of WebSphere Business Modeler. Advanced mode lets you to see more technical details of your process. For the following set of steps, you need to be in Advanced mode, or one of the export modes like WebSphere Process Server mode. Typically an I/T technical resource performs this work. Figure 15 shows how to select Advanced mode:
Figure 15. Changing to Advanced mode
When Modeler changes to Advanced mode, the visual representation changes to show more details, such as the input and output ports for each task. In addition, more tabs appear in the Attributes pane. While Basic mode is optimized for a non-technical business analyst, Advanced mode is optimized for a technical user. Figure 16 shows our example process in Advanced mode:
Figure 16. Process edited in Advanced mode
Updating the While Loop
We can now set the advanced properties of the loop. Make sure you are in Advanced mode.
- Click on the + in While Loop to expand it.
- Select Repeat Task and click on the Inputs tab. Because you are in Advanced mode, additional information now appears, such as the Input Source column.
- Click Add to add a second input to the task. The existing input from the Start Node is for the control of the flow in simulation. The new input will be for data.
Tip: It might be easier to edit by double-clicking the Attributes tab to expand the pane to full screen size. You can double-click again to restore it to the previous size. Alternatively, you can move the cursor over the edge between the two panes, then click and drag to make the Attributes pane larger, as Figure 17 shows:
Figure 17. Double-click Attributes to expand
- Click on the Associate Data field for the new input, or click Browse.
- Select the Data business item.
- Ensure you are still on the Inputs tab for Repeat Task, as Figure 18 shows:
Figure 18. The inputs tab
Setting the input source
The task now has a new input, associated with Data. As a default, the source for the input is set to Flow, meaning that the data flows from a previous task. Repeat Task needs to get its input from a Repository instead.
- Click Input Source, (which has defaulted to Flow). From the pull-down menu, select Repository, as Figure 19 shows:
Figure 19. Input source pull-down menu
- Press Enter or click off to the side to keep Repository as the selected value. The rest of the input tab changes because of the new source you selected, as Figure 20 shows:
Figure 20. Repository details
- Click the Browse button next to the Repository value list to select which repository to pull the data from.
- Select the local repository called Loop Process/Loop Data Store , as Figure 21 shows:
Figure 21. Selecting the Repository Value
Adding a new Output to the task
In a similar manner, we need to define a new Output needs for Repeat Taskto send the results to the Repository.
- Click on the Outputs tab.
- Add a new Output and associate it with the Data business item.
- Ensure you are still on the Outputs tab. Set the Output Target to Repository.
- Select Loop Process/Loop Data Store as the Repository value.
- Press Ctrl-S to save your work. Figure 22 shows the completed loop:
Figure 22. The completed loop
Adding the Loop Condition
A loop has an attribute called a Loop Condition, which controls the flow. For a While Loop, it evaluates the Loop Condition before the loop starts. If it evaluates to
True, it runs the steps in the loop. If it evaluates to False, the loop ends, and the flow returns to the process that called the loop. In our example, the While Loop needs to run until the Status field in the Data business item is set to Done.
- Right-click the background of the design surface, and select Root to navigate back to the high level process.
- Click While Loop to ensure it is selected.
- Click the Loop Condition tab. This tab does not appear in Basic mode.
- Enter a probability for simulations. Remember that in the original process, 20% of the time the work was not done, and the task had to be repeated. Set the probability to
20.0.
- Optionally, enter a description, as in Figure 23:
Figure 23. Editing the loop condition tab
Define the expression for the Loop Condition
If you were only simulating the process, you would be finished. However, this process will also be exported to WS-BPEL, so we also need to define the details of how to make the decision.
- Click Edit… to define the Expression for the Loop Condition.
- In the First term list, ensure Modeling Artifact is selected. Expand Processes by clicking on the +, and expand Loop Process and Loop Data Store. Select the Status field.
- From the Operator list, select Is equal to.
- In the Second term list, select Text from the pull-down. Set the value to Done, so that the Expression Builder window looks like Figure 24:
Figure 24. Editing the Loop Condition expression
- Click Apply. If you don’t apply the expression before clicking OK, your work will not be saved.
- Ensure that the Expression text is updated with your expression.
- Click OK. You will see the expression text in the Loop Condition tab now.
- Press Ctrl-S to save your work.
Set the Repository size
As a default, the repository size is unlimited. This means that it can contain any number of business item instances. When exporting to WS-BPEL, the repository is transformed into a BPEL variable defined as an array. However, in this case we only need a simple variable. We need to set the repository size to 1 to generate a simple BPEL variable.
- Click Loop Data Store in the process to select it, and click the Repository Details tab.
- Uncheck the box for Unlimited capacity.
- Make sure the capacity is set to 1 (Figure 31) and press Ctrl-S to save your work.
Figure 25. Setting the repository size
Simulating the process
With the updates you made to the process, it should now simulate properly. Let’s test it out:
- Right click on Loop Process in the Process Tree.
- Select Simulate. The simulation editor opens.
- Click the Control Panel tab and click the green arrowhead to start simulation. If you are using using version 6.0.2, accept the pop-up for checking paths for Stop Nodes and click OK when validation completes.
- If you’ve followed all the steps in this article correctly, the simulation runs properly. If not you might need to retrace your steps to spot the problem.
Exporting the process
Now we can finally export the process to WS-BPEL:
- Right-click on Loop Process in the Process Tree and select Export.
- Select WebSphere Process Server as the type and click Next.
- Enter a target directory to contain the exported process.
- Select Export specific elements. Since Original Process will not export properly we just want to select our corrected process.
- Select a Module project name, and enter
LoopProcessModule.
- Click Finish.
Figure 26. Exporting to WS-BPEL
Tip: You may get some warnings about certain attributes not being supported. This is normal, so you can ignore the message.
Examining the generated WS-BPEL
You can use IBM WebSphere Integration Developer (hereafter called Integration Developer) to edit the process. If you have installed Modeler in the same Eclipse shell, you can simply switch to the Business Integration perspective. If not, start Integration Developer and point the workspace to the directory where you just exported your model. Figure 27 shows the generated WS-BPEL in Integration Developer. Let’s explore the generated code.
Figure 27. The generated WS-BPEL
-
First Task, Repeat Task and Last Task are BPEL Invoke activities.
-
While Loop corresponds to our While Loop, and contains Repeat Task.
-
DataVariable was generated from the Data business item.
-
DataVariable2 was generated from the repository.
- Click on First Task to examine its properties, as Figure 24 shows:
Figure 28. First Task properties
-
First Task gets its Input from DataVariable, which came from the business item. It sends its Output to DataVariable2, which came from the repository, which is exactly what we expected.
- Examine the other Invoke tasks to verify that they too use the variables based on the business model.
- Click the While Loop to examine its properties.
Figure 29. While Loop properties
- Click the Details tab to see the generated expression. It compares the field
Status with the string value of Done, just as designed.
Conclusion
This article showed how to update a process where a business analyst used improper notation to make it properly simulate and export to WS-BPEL.
Download | Description | Name | Size | Download method |
|---|
| Modeler sample project | loopproject.zip | 127KB | FTP | HTTP |
|---|
Resources Learn
Get products and technologies
About the author  | 
|  | Marc Fasbinder is an I/T Specialist at IBM with the WebSphere Technical Sales team in Southfield, Michigan. You can reach Marc at mfasbind@us.ibm.com. |
Rate this page
|  |