This example shows how to apply mathematical functions to the policy holder coverage
elements from the group of customers obtained from the Expiring Policies
data mashup stored in the catalog. Saved data mashups can always be used as sources for other data mashups. Aggregate information such as count
is displayed for the policy and coverage amounts in the output XML.
Before you begin
Estimated time to complete this example
: 15 minutes
About this task
The Aggregate Policies Data Mashup
is available in the catalog when you install Mashup Center. Compare the data mashup you are working on to the completed data mashup in the catalog to help you understand how to build data mashups. To view the data mashup example and its details, select the data mashup from the catalog. Select Edit As New
to bring up another data mashup builder tab. You can compare the contents of the two data mashups in the two tabs.
The Aggregate Policies Data Mashup is composed of three data mashup builder operators:
- Source operator: Imports data from the first data mashup, Expiring Policies, as a source of aggregated data.
- Transform operator: Performs mathematical functions like minimum, maximum, total and average, on the aggregated data.
- Publish operator: Publishes the results as an Atom feed.
Information about adding operators to the canvas, along with other tips, can be found in the data mashup builder help. This help is available in the data mashup builder, on the right of the action bar by clicking the ?
The Mashup Center installation contains many example objects that might change in future releases. Do not import any of the preinstalled examples into the Source operator when you build a data mashup. Instead, create a copy of that example for your own use by following the example instructions.
Table of contents
- Overview of Tasks
- Connection to the Internet
- Supported browser
- Internet Explorer 6.0 SP3, 7.0, 8.0 (Windows® only)
- Mozilla Firefox 3.6 (Windows and Linux®)
- Safari 5.0 (Mac OS only)
- For the most current information about system configuration, consult the Detailed System Requirements for IBM® Mashup Center.
- Logged in to Mashup Center
Overview of tasks
- Start the data mashup builder.
- Add a source to import the Expiring Policies feed.
- Preview the data.
- Add a Transform operator and create new elements.
- Use the Count function to calculate the value for the num_policyholders element.
- Publish the data mashup in Atom format.
- Run the data mashup to verify the output.
- Save the data mashup to the catalog.
- On the Home:Catalog page, click Create and select New Data Mashup to start the data mashup builder.
- Add a Source operator to import the Expiring Policies feed:
- Double-click the Source operator from the left side of the data mashup builder. The operator is placed on the canvas and the Source operator window opens.
Tip: An alternative method is to click and drag the operator from the left side of the data mashup builder to the canvas.
- From the Properties tab, type Aggregate in the Name area.
- Select From Catalog and click Browse.
- Type Expiring Policies in the search area and click Search.
- Select the feed called Expiring Policies Data Mashup and click OK.
- From the Advanced tab, select the following values;
- Feed Type: XML
- Repeating Element: Click the arrow in the Repeating Element and select the feed element. The feed element is the root element of the feed.
Tip: Whenever the Aggregation functions are used, the root or higher level element of the feed must be selected as the Repeating Element of the incoming feed. In this example instead of the child entry elements being selected, the aggregate calculations need to be performed on all like elements instead of individual elements. For instance, all of the premium elements will be used in the max aggregate function to determine the one entry that contains the maximum premium value. If the default value of /atom:feed/atom:entry was selected for the Repeating Element in the Advanced Tab, calculations would be performed on each entry. The calculation would not be an aggregation, but instead a calculation on individual entries.
Preview the data:
Add a Transform operator and create new elements:
- Click the Preview tab to view the data.
- Expand entry > feed > entry to see the coverage and premium elements.
These elements are used in each of the mathematical functions used in later steps.
- Close the Source operator window.
- Double-click the Transform operator to place it on the canvas.
- Drag the Transform operator to the right of the Source operator.
- Drag the plug of the Source operator to the socket of the Transform operator.
- Click the Transform operator to open the Transform operator window.
Tip: The first operator placed on a new canvas of the data mashup builder automatically opens the operator details window. Each subsequent operator must be clicked to open the operator details window.
- Create new elements for the Output entry element. This establishes the Output element set which will be populated with data later.
Use the Count function to calculate the value for the num_policyholders element:
- Right click the entry element in the Output region and select New Element.
- Erase new in the new element field and type num_policyholders. Click Enter.
- Create eight more new elements using the same steps as the num_policyholders element, and name them according to the following list:
Publish the data mashup in Atom format:
- In the Output region of the Transform operator properties page, right-click the num_policyholders element and select Specify a function value. The Choose Function window opens.
- From the Aggregate functions list, select Count.
- Click the arrow in the Value box and select Specify a value from the Input tree.
- Expand feed -> entry -> lastname. Select the text value under the lastname element. Selecting the text value for the lastname element.
- Click OK to close the Choose from the tree window.
- Click OK to close the Count window.
Selecting a repeating element of /atom:feed instead of /atom:feed/atom:entry in the Source operator means the Count calculation is performed on all lastname elements, instead of the individual lastname elements contained within each entry.
- Repeat steps 5.a. through 5.f. Right-click the total_coverage element and calculate the Sum for the coverage element.
- Repeat steps 5.a. through 5.f. Right-click the max_coverage element and calculate the Max for the coverage element.
- Repeat steps 5.a. through 5.f. Right-click the min_coverage element and calculate the Min for the coverage element.
- Repeat steps 5.a. through 5.f. Right-click the avg_coverage element and calculate the Avg for the coverage element.
- Repeat steps 5.a. through 5.f to calculate values for each of the four respective premium elements. Use the appropriate aggregate function for each premium element.
- Click the Preview tab to view the results.
- Close the Transform operator window.
- Connect the Transform operator to the Publish operator.
- Click the Publish operator to open the Publish operator window.
- From the Properties Tab, type or select the following values:
Close the Publish operator window.
- Feed Type: ATOM
- Title: Aggregate Policies Data Mashup
- Author: Your user name.
- Rights: All
Run the data mashup to verify the output:
Save the data mashup to the catalog:
- Click the Run icon to run the data mashup.
Running the data mashup displays the results in a new tab or window in the browser.
- Click the Save icon to save the data mashup to the catalog.
- In the Save window type or select the following values:
- Title: My Aggregate Policies Data Mashup
- Description: Aggregation of coverages and premiums data mashup example
- Version: 1.0
- Tags: aggregate functions, example data mashup
PROBLEM: No data is presented when previewing or running the data mashup.
- The Policy Holders feed used in this data mashup has a static set of data. Specifying a year and month not contained in this data set will result in an empty feed. View the output from the Policy Holders feed outside of the data mashup or before the Filter operator (e.g. the preview tab of the Source operator) and make note of valid enddates. Use only months and years that are referenced in the source data.
If problems persist, post a problem description or question to the Mashup Center forum