Initialize the process variables responsible for controlling the
loop and output stock portfolio.
To add a snippet to assign the counter and numberOfSymbols variables
to the PortfolioEvaluatorProcess process, follow these steps:
- Let's begin by initializing the counter variable that is used as
an index when retrieving and storing stock information, as follows:
- In the process editor, click
on the palette and then
.
- Click the connection between Receive and Reply.
The Snippet activity was added.
- Rename Snippet to Initialize
variables by typing over the highlighted text.
- In the Properties view, click Details.
- Click the Expression icon
on the
palette, then add the expression to the canvas and type 0 as
the value.
- Drag the existing counter variable from
the tray to the canvas. Hover over the 0 figure and
drag the yellow handle to the counter variable to create
a connection between the figures.

- Next, we'll use a Java visual snippet to assign the size of the
stock portfolio to a variable, as follows:
- Drag the existing InputStockPortfolio variable
from the tray onto the canvas. Click on the label and select .
- Click
on the palette, which is the Java™ icon. The Select
a Java Visual Snippet window opens.
- In the Specify a type (? = any character, * = any
String) field, type java.util.List.
- Click List. The qualifier java.util
- <WSInstallDir>/runtimes/bi_v6/java/jre/lib/core.jar will be
selected.
- Click size() and then OK.
- Click on the InputStockPortfolio.stockInfoList figure.
A connection is created between the InputStockPortfolio.stockInfoList figure
and the size figure.
- Drag the existing numberOfSymbols variable
from the tray over the size figure. A connection is
created between both figures.

- Assign a new StockPortfolioBO to the output
variable of the process, OutputStockPortfolio:
- Click
on the palette. The Add a Standard Visual Snippet window
opens.
- In the navigation tree, click SCA services > create
specific BO and click OK. The Data
Type Selection window opens.
- In the Filter by type, namespace, or file (? = any
character, * = any String) field, type StockPortfolioBO.
- Click StockPortfolioBO and click OK.
Click the canvas to add the activity.
- Add the existing OutputStockPortfolio to
the canvas.
- Connect the create StockPortfolioBO figure
to the OutputStockPortfolio figure.

- Initialize the value for the output stock portfolio:
- Click
on the palette, which is the Expression icon.
- Click the canvas to add the expression and type 0 as
the value.
- Add the existing OutputStockPortfolio variable
to the canvas, click on the label and select .
- Connect the 0 figure to the OutputStockPortfolio.value figure.

- Create an ArrayList Java visual snippet for the output stock portfolio
to hold the StockInfoBOs, each containing information for one stock:
- Click
on the palette, which is the Java™ icon.
The Select a Java Visual Snippet window opens.
- In the Specify a type (? = any character, * = any
String) field, type java.util.ArrayList.
- Click ArrayList.
- Click java.util - <WSInstallDir>/runtimes/bi_v6/java/jre/lib/core.jar.
- Click ArrayList() and then click OK.
Click the canvas to add the activity.
- Add the existing OutputStockPortfolio to
the canvas, click on the label and select .
- Connect the new ArrayList figure to the OutputStockPortfolio.stockInfoList figure.

The entire set of visual snippets for initializing and setting the
variables is now be complete, as shown in the figure below:

Now that we have assigned
a stock portfolio to the variable used for the process output and we have
initialized the variables, next we will create the loop to contain activities
responsible for calculating the stock portfolio's value.