Now we are ready to iterate over the rows that the ActionSetSvc can provide to us.
We will be first calling the newly created DB adapter and then iterating over the results.
Drag and drop invoke into the “If free vehicle moving” section. Drag a line from it to the ActionSetSvc and a dialog will open. Name the invoke and create input and output variables. The output variable will be a set of rows (A collection)
Drag an assignment before the invoke and name it “AssignGetActionsParams”.
Double click on the Assign operation. Create a copy operation from the LocationId on the ReceiveGeoFenceEvent_InputVariable to ActionSetSvcSelect_input parameters location parameter.
Press Ok. We have now called the db adapter and are ready to iterate over it.
Let’s first count the number of returned rows.
Start by adding a new variable. We could make this a local variable this time as we do not need the loop counter anywhere else. For this we need to add a scope. Drag and drop a scope before the assign operation. BTW: The scope thing here is optional. The composite would work perfectly also with global variables.
Move the Assing and invoke inside the scope
Add a variable by pressing the (x) icon (might be somewhat hard to see as it is in light grey, the tooltip says Variables…)
Press green plus to add a new variable. Name it RowCount and make it integer from XML Schema Simple types.
Add another variable called for example i that is also an integer.
Next set the value for the variable. Add an assignment operation after the invokegetoperations. Name it AssingLoopCounter. Double click on it. In the Copy Rules section there is a folder like icon on the right side with name Variable. Open it and locate LoopCounter.
Drag the function icon on top of the RowCountvariable and the editor opens up.
Insert SimpleActionCollection under the InvokeGetActions_OutputVarible to the Expression area by pressing the “Insert into Expression” button. The end result is like this:
$InvokeGetActions_OutputVariable.SimpleActionCollectionWe need to wrap this with either count() or ora:countNodes-operation. Operations are on the right
The count is under Mathematical Functiona dn ora:countNodes is under BPEL Xpath Expression Functions. Add the count operation to the Expression area so that end result looks like this:count($InvokeGetActions_OutputVariable.SimpleActionCollection)
Also add assignment to set i-variable to 1.
Drag and drop a while to the canvas after the AssignLoopCounter and still inside the scope.
Let’s do the loop over the items in list. The first item in XPATH expressions is always 1 by the way.Add assignment to the end of the while area (there is text add Activity here on canvas, drag and drop assignment operation there and double click on it.) Set I = i+1. Name the assignment IncrementLoopCounter.
Double click on the while icon. A dialog opens up where we set the termination condition for the loop.
The termination code should be: $i<=$RowCount
The flow should look like this:
We have everything but we are still not launching any action as a response. We could have an external web service that does the actions for us (fairly common option) but let’s assume we have inherited a group of scripts and need to launch those as a response. To do that we need to have a small wrapper that calls scripts and next we shall develop one.