Create the while loop activity to contain activities that get each
stock quote, grab the stock information and store the data in a business object.
We need to add a while loop activity and also define a boolean expression
for it to ensure that the activities within the scope of the loop only obtain
information for each stock once. This expression will compare the current
counter to the number of symbols in the stock portfolio, and return either
true or false.
To add the while activity to the PortfolioEvaluatorProcess
process, follow these steps:
- In the process editor, click
on the palette and then
, which is the WhileLoop icon.
- Click the connection between Initialize variables and Reply.
The WhileLoop activity was added.
- Now that the activity is in the business process, we must add the
boolean expression. If the value returned from the expression happens to be true,
the loop will continue. However, if the value is false, the loop will
terminate and the process will advance to the Reply activity.
To make this expression, follow these steps:
- In the Properties view, click Details.
- From the Expression language list, click Java.
- Remove the existing false and return figures
from the canvas. After that, drag the existing counter and numberOfSymbols variables
from the tray onto the canvas.
- Click
on the palette. The Add a Standard Visual Snippet window
opens.
- In the navigation tree, click and then click OK.
Click the canvas to add the activity.
- Click
on the palette, which is the Return icon,
and click the canvas to add the activity.
- Connect the counter and numberOfSymbols figures
to the less than figure.
- Connect the less than figure to the return figure
to complete the expression, as shown in the following figure:

Now that we have a WhileLoop activity to contain the business logic
responsible for updating the stock portfolio, next we can initialize the variables
that store stock quote information.