This example shows how to create a data mashup that pivots data, which is useful when you want data values to display as column headers in a table widget.
Before you begin
Estimated time to complete this example
: 25 minutes
About this task
In this Dynamic Rename Data Mashup
example, the data values of the Team Hours
feed (available in the catalog) are pivoted into element names.
When the Team Hours
feed is displayed in a table widget, the output displays the hours each team spent in each category in multiple rows, as in this example of Team-A's output:
When the Team Hours are presented in table widget output, however, you cannot easily compare the hours each team spent in a specific category.
Using the same Team Hours
feed data, the dynamic rename data mashup output presents the data as one row per team, as in this example of teams F through B:
The Dynamic Rename Data Mashup
is composed of these data mashup builder operators:
- Source operator: Imports the data from the Team Hours feed, which is available in the Mashup Center catalog.
- Group operator: Creates groups for each Team to display one row per Team in the Data Viewer/ Table Viewer widget.
- Transform operator: Performs the dynamic rename of elements.
Note: It is beneficial to configure Dynamic Rename as late in the data mashup as possible. Otherwise you may need to repeat actions for every element that has a different name.
- Publish operator: Outputs the data in Atom format.
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 Team Hours feed.
- Add a Group operator to group the Teams to display one row per Team in the Data Viewer.
- Add a Transform operator to perform the dynamic rename of elements.
- Publish the data mashup as an ATOM feed.
- Run the data mashup to verify the output.
- Save the data mashup to the catalog.
- Verify the feed output.
- On the Home:Catalog page, click Create and select New Data Mashup to start the data mashup builder.
- Add a source to import the Team Hours 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 Team Hours in the Name area.
- Select From Catalog and click Browse. Type Team Hours in the search area and click Search.
- Select the Team Hours Feed item. Click OK.
- Click Close.
- Add a Group operator to group the Teams to display one row per Team in the Data Viewer:
- Double-click the Group operator to place it on the canvas.
- Drag the Group operator to the right of the renamed Source operator.
- Drag the plug of the Group operator to the socket of the renamed Source operator.
- Click the Group operator to open the Group operator window.
- On the Properties tab, type Group Teams in the Name area.
- In the Group expression field, click the arrow and select Specify a value from the input tree.
- In the Choose from the tree dialog, expand content -> row, select the Team element and click OK.
- In the Associated data expression field, click the arrow and select Specify a value from the input tree.
- In the Choose from the tree dialog, expand content, select row, and click OK.
- Click the Preview tab and examine the data.
There are now six entries, one for each team. Each entry contains one Team element and five associated row elements. The row elements contain all the data for the given team.
- Close the Group operator window.
- Add a Transform operator to perform the dynamic rename of elements:
- Double-click the Transform operator to place it on the canvas.
- Drag the Transform operator to the right of the Group operator and connect them.
- Click the Transform operator to open the Transform operator window.
- From the Properties tab type Dyn Rename in the Name area.
- To copy the Team element from the Input region to the Output region which establishes the output data set:
- Click the entry element in the output area to mark the location in the output tree to copy the input element.
- Right-click the Team element from the Input region and select Copy to the output tree.
- To create an element whose name will be dynamically generated based on the category names of the current entry:
- Right-click the entry element in the Output region and select New Element.
- Erase new in the new element field and type Category.
- To dynamically rename the element with the category name from the input region:
- In the Output region right-click the Category element and select Edit.
- Click the arrow in the Expression field and select Specify a value from the input tree.
- Expand row -> Category, and select the text value under the Category element. Click OK.
In the Edit Element Name dialog the category expression selected from the tree is displayed. If the expression you selected returns no value, the Edit Element Name default name is used.
Note: This is the key step of the dynamic rename example. The element name in the output region of the Details window should be dynamically renamed with the value of the Category element selected from the input tree. This action generates specific elements with the category name of the entry (such as Administrative), instead a static element called Category.
- Click OK.
- Add the Hours value to the Category element:
- Click the Category element in the Output region to mark the location in the Output tree to copy the Hours value.
- Expand row -> Hours in the Input region.
- Right-click the text node under Hours and select Copy to the output tree.
The text node is selected because it contains the value of the element.
- Click Preview and examine the data.
Instead of multiple row elements for each of the grouped Team
entries, there are now five new elements, each of which is named after a single category. The value beneath each of the new elements is the number of hours that the team spent in that category.
- Close the Transform operator window.
- Publish the data mashup as an Atom feed:
- Connect the Transform operator to the Publish operator.
- Click the Publish operator to open the Publish operator window.
- From the Properties tab, select the following values:
Close the Publish operator window.
- Header: Default
- Feed Type: ATOM
- Title: Dynamic Rename Data Mashup Example
- Author: Your user name
Run the data mashup to verify the output:
Save the data mashup to the catalog:
- Click the Run icon to run the data mashup and view the results as XML.
Running the data mashup displays the results in a new tab or window in the browser. There is an entry for each of the Teams containing the categories and the hours spent for each category. The output looks like this example:
- Click the Save icon to save the data mashup to the catalog.
- In the Save window, type or select the following values;
- Title: My Dynamic Rename Data Mashup Example
- Description: Dynamic Rename Data Mashup to convert data values into column headers.
- Tags: Team Hours, Dynamic Rename
Verify the feed output:
- To verify that the data mashup provides the correct output, view the feed in the table widget / Data Viewer:
- Click the View data mashup properties icon.
- Click Permalink URL.
- Click View Feed in a Table Widget.