< Previous | Next >

Adding a snippet to assign the counter and numberOfSymbols variables

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:
  1. Let's begin by initializing the counter variable that is used as an index when retrieving and storing stock information, as follows:
    1. In the process editor, click Empty icon on the palette and then Snippet icon.
    2. Click the connection between Receive and Reply. The Snippet activity was added.
    3. Rename Snippet to Initialize variables by typing over the highlighted text.
    4. In the Properties view, click Details.
    5. Click the Expression icon Expression icon on the palette, then add the expression to the canvas and type 0 as the value.
    6. 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.
      Assign 0 to counter
  2. Next, we'll use a Java visual snippet to assign the size of the stock portfolio to a variable, as follows:
    1. Drag the existing InputStockPortfolio variable from the tray onto the canvas. Click on the label and select inputStockPortfolio > stockInfoList.
    2. Click Java icon on the palette, which is the Java™ icon. The Select a Java Visual Snippet window opens.
    3. In the Specify a type (? = any character, * = any String) field, type java.util.List.
    4. Click List. The qualifier java.util - <WSInstallDir>/runtimes/bi_v6/java/jre/lib/core.jar will be selected.
    5. Click size() and then OK.
    6. Click on the InputStockPortfolio.stockInfoList figure. A connection is created between the InputStockPortfolio.stockInfoList figure and the size figure.
    7. Drag the existing numberOfSymbols variable from the tray over the size figure. A connection is created between both figures.
      Assign the number of stocks to numberOfSymbols
  3. Assign a new StockPortfolioBO to the output variable of the process, OutputStockPortfolio:
    1. Click Standard icon on the palette. The Add a Standard Visual Snippet window opens.
    2. In the navigation tree, click SCA services > create specific BO and click OK. The Data Type Selection window opens.
    3. In the Filter by type, namespace, or file (? = any character, * = any String) field, type StockPortfolioBO.
    4. Click StockPortfolioBO and click OK. Click the canvas to add the activity.
    5. Add the existing OutputStockPortfolio to the canvas.
    6. Connect the create StockPortfolioBO figure to the OutputStockPortfolio figure.
      Assigning a StockPortfolioBO to the OutputStockPortfolio variable
  4. Initialize the value for the output stock portfolio:
    1. Click Expression icon on the palette, which is the Expression icon.
    2. Click the canvas to add the expression and type 0 as the value.
    3. Add the existing OutputStockPortfolio variable to the canvas, click on the label and select OutputStockPortfolio > value.
    4. Connect the 0 figure to the OutputStockPortfolio.value figure.
      Give OutputStockPortfolio and value of 0
  5. Create an ArrayList Java visual snippet for the output stock portfolio to hold the StockInfoBOs, each containing information for one stock:
    1. Click Java icon on the palette, which is the Java™ icon. The Select a Java Visual Snippet window opens.
    2. In the Specify a type (? = any character, * = any String) field, type java.util.ArrayList.
    3. Click ArrayList.
    4. Click java.util - <WSInstallDir>/runtimes/bi_v6/java/jre/lib/core.jar.
    5. Click ArrayList() and then click OK. Click the canvas to add the activity.
    6. Add the existing OutputStockPortfolio to the canvas, click on the label and select OutputStockPortfolio > stockInfoList.
    7. Connect the new ArrayList figure to the OutputStockPortfolio.stockInfoList figure.
      Give OutputStockPorfolio a new ArrayList for stocks
The entire set of visual snippets for initializing and setting the variables is now be complete, as shown in the figure below:
Complete snippet

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.

Feedback
(C) Copyright IBM Corporation 2005, 2007. All Rights Reserved.
< Previous | Next >