Apply Operators on Sub Node of a Cluster
There are scenarios where we need to handle clustered data. One reason could be that the actual data is clustered. Another may be that we deal with a Web Service, and the meaningful data appears as a sub-node under the root. Either way, we may need to operate on a sub-node of the cluster – data that is not in the root. For example: Filter that data.
The application may look like this:
Now, assume that we want to filter the data on the address level, for example: the address of the currently selected supplier.
Here is the same application, only now we filter out address records where the country equals china. Notice the supplier Oy has one address less than before.
In the current model, we show the suppliers in the first Grid View, where the Context Node is supplier_list. Any operator we connect after this Grid View could operate on fields of this node alone.
We need to somehow get the address list for a selected supplier, so we can pass it to the operator. A dedicated Service Component can do just that: The input port gets the hierarchy of selected supplier with the addresses sub-node. The output returns the flat list of addresses:
Here are the required modeling steps:
1. Add a Service Component to the model.
Model the Service Component:
2. Add a Data In element. In the Define Data dialog set it to contain the full supplier hierarchy. Set the root Cardinality to 1..1 (use the View => Hierarchy Tree option to define the clustered data).
3. Add a Data Out element. In Define Data set the same hierarchy minus the original root.
4. Define the mapping to copy the rows from the source sub-node to the target root:
For this type of “sub-node to root” mapping, we need to have at least one difference between source and target fields, so we get the diamond shape on the mapping link.
Back in the main model:
5. Open the Redefine Ports dialog for the new Service Component and select the new ports.
6. Connect the new service to model elements.
7. It is now possible to define the desired filter on the address level:
Other cluster related documents: