Take the stock information gathered from the stock quote web service
and add it to the stock portfolio.
To add a snippet to assign the OutputStockPortfolio variable to the
process:
- Create an activity that adds stock values to the stock portfolio:
- In the process editor, click
on the palette, and then
.
- Click in the WhileLoop activity below
the getQuote activity. The Snippet activity
was added.
- Rename Snippet to Assign OutputStockPortfolio by
typing over the highlighted text.
- Assign the share price received from the stock quote web service
to a variable:
- In the Properties view, click the Details tab.
- Add the existing getQuoteOutput variable
to the canvas.
- Add the existing stockInfo variable to
the canvas, click on the label and select .
- Connect the getQuoteOutput figure to
the stockInfo.pricePerShare figure.

- Now that we have both the price per share and the quantity of the
stock in question, take the product of those two values and add it to the
stock portfolio's value:
- Add the stockInfo.pricePerShare variable
to the canvas again.
- Add stockInfo one more time to the canvas,
click on the label and select .
- Click
on the palette, which is the Standard icon.
The Add a Standard Visual Snippet window opens.
- In the navigation tree, click and click OK.
Click the canvas to add the activity.
- Connect the stockInfo.pricePerShare and stockInfo.quantity figures
to the multiply figure. This activity will now multiply
the price per share received from the web service with the quantity stated
in InputStockPortfolio.
- Add the existing OutputStockPortfolio to
the canvas, click on the label and select .
- Click
on the palette. The Add a Standard Visual Snippet window
opens.
- In the navigation tree, click math > add and
click OK. Click the canvas to add the activity.
- Add the existing OutputStockPortfolio to
the canvas and drill into OutputStockPortfolio.value.
- Connect the multiply and the first OutputStockPortfolio.value figures
to the add figure.
- Connect the add figure
to the second OutputStockPortfolio.value figure. This
will add the total value of the stock to the stock portfolio's value.

- Create a copy of the stock information:
- Add the existing stockInfo variable to
the canvas.
- Click
on the palette. The Add a Standard Visual Snippet window
opens.
- In the navigation tree, click and click OK.
Click the canvas to add the activity.
- Click
on the palette. Add the expression to the canvas and type stockInfoCopy as
the label.
- Right-click the stockInfoCopy figure
and from the pop-up menu, select Set Type > Business Object .
The Data Type Selection window opens.
- In the Filter by type, namespace, or file (? = any
character, * = any String) field, type StockInfoBO.
- Click StockInfoBO and click OK.
- Connect the stockInfo figure to the copyBO figure.
- Connect the copy BO figure to the stockInfoCopy figure.

- Add the acquired stock information to the stock portfolio:
- Add the existing OutputStockPortfolio to
the canvas, click on the label and select .
- 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 java.util - <WSInstallDir>/runtimes/bi_v6/java/jre/lib/core.jar.
- Click add(Object) and click OK.
Click the canvas to add the activity.
- Connect the OutputStockPortfolio.stockInfoList figure
to the add figure.
- Connect the stockInfoCopy figure to the add figure.
This will add the stock information to the stock list in the portfolio.

- Increment the counter representing the index of the stock in the
stock list:
- Add the existing counter variable to
the canvas.
- Click
on the palette, which is the Expression icon.
- Add the expression to the canvas and type 1 as
the value.
- Click
on the palette. The Add a Standard Visual Snippet window
opens.
- In the navigation tree, click and click OK.
Click the canvas to add the activity.
- Add the existing counter variable to
the canvas.
- Connect the first counter figure to the add figure.
- Connect the 1 figure to the add figure.
- Connect the add figure to the second counter figure.
This will increment the value of counter by 1.

You should now have the following visual snippet:

With the assignment
of the output variable, the activities within the WhileLoop activity are now
complete. The combination of the three activities serve to grab stock quotes
by invoking the web service, and then calculating the stock portfolio's value
based on the new information. All of the assignments and calculations within
the process are performed by the visual snippets that you've created.