Create a snippet to retrieve the stock information from the list
in the portfolio and then store it. This is completed based on a counter value
that corresponds to a unique index in the list of business objects that represent
stocks.
To add a snippet to assign the getQuoteInput variable to the process:
- Get the stock information using the counter as an index:
- In the process editor, click
on the palette.
- Click inside the WhileLoop activity.
The Snippet activity was added.
- Rename Snippet to Assign getQuoteInput by
typing over the highlighted text.
- In the Properties view, click Details.
- Drag the existing InputStockPortfolio variable
from the tray onto the canvas. Click on the label, then select.
- Drag the existing counter variable from
the tray onto the canvas.
- Click
on the palette. The Select a Java Visual Snippet window
opens.
- In the Specify a type (? = any character, * = any
String) field, type java.util.List.
- Click List.
- Click get(int) and click OK.
- Click on the InputStockPortfolio.stockInfoList figure
to add the get activity and connect the two figures.
- Connect the counter figure to the get figure.
- Drag the existing stockInfo variable
from the tray and onto the canvas.
- Connect the get figure to the stockInfo figure.

- With the stock information now contained in stockInfo, we must
assign the stock symbol to getQuoteInput:
- Drag the existing stockInfo variable
from the tray onto the canvas. Click on the label and select .
- Drag the existing getQuoteInput variable
from the tray over the stockInfo.symbol figure on the
canvas. A connection is created between both figures.

The visual snippet should now look like this:

Now that we have assigned the stock symbol to the getInputQuote
variable, next we will use it as an identifier to obtain the stock quote with
the web service.