Monday, August 15, 2011

WPS: Creating Relationships

Introduction:
The relationship service has two distinct relationship types: static and dynamic. Static relationships are used to map between non-primary key values, where the data does not change frequently (such as zip codes). Dynamic relationships are used to define correlations on the key attributes that uniquely identify the business objects.

There are two enterprise systems, each with its own representation of data that needs to be associated through the relationship service.

Creating Relationship :  Static (Which data need not change frequently)
  1. Start WebSphere Integration Developer (hereafter called Integration Developer) and create a new workspace.
  2. Choose File > New Mediation Module.
  3. Name the module RelationshipService.
  4. Create BusinessObjects.
  5. Create Interfaces.
  6. Define Mediation Module and Create BO map.
  7. Create relationship, enter static data and reference it into BO map.
  8. Test the Module.

    Creating BusinessObject :
    • In Integration Developer Project, select DataTypes > New > Business Object.
    • Enter the details for the Namespace and the Name as shown in Figure1. 
    Figure : 1
     
    • Click Finish.
    • The Business Object editor opens. For the WPSCustomer Business Object, add three string fields called:
              fName
              lName
              id
    • The Business Object editor opens. For the WPSDetailCustomer Business Object, add three string fields called:
              CustName
              LastName
              DeptNumber
    Create the interfaces
    1. Return to the assembly diagram.
    2. Click the RelationshipService mediation and click Add interface.
    3. In the “Add interface” dialog box, select New.
    4. In the “New interface” dialog box, enter name of WPSEvent as shown in Figure2.
    5. Click Finish.
    6. The Interface editor opens. Click the Add One Way Operation icon.
    7. Set the operation name as incomingMessage, the input name as customerIn, and the type as WPSCustomer.
    8. Select File > Save.
    Figure 2:
    Figure 3: 











    1. In the “New interface” dialog box, enter name of WPSDetailEvent as shown in Figure2.
    2. Click Finish.
    3. The Interface editor opens. Click the Add One Way Operation icon.
    4. Set the operation name as receiveMessage, the input name as customerOut, and the type as WPSDetailCustomer.
    5. Select File > Save.
      Implementation of Mediation and BO Map:
    1. Return to the assembly diagram and double-click on RelationshipService.
    2. A message displays indicating that the selected component is not implemented. Click Yes.
    3. In the “Generate Implementation” dialog box, click OK.
    4. The Operations Overview is now displayed. And input incomingMessage : WPSEvent is appeared.
    5. From the primitives pallet, select Transformations > Business Object Map and drag the primitive onto the flow.
    6. Wire up the Business Object map terminals to the input and callout terminals as shown in Figure 4.
    7. In the “New Business Object Map” dialog add map name as "MD_WPSCustomer_To_WPSDetailCustomer"
    8. Click Finish.
     
     Figure 5:
    1. Click the + symbols to expand out both business objects.
    2. Drag a connection from the Name field on the left business object to the fName field on the right business object. Repeat this for the lName field.
    3. Perform this one more time for the town field. Once completed, click on the Move operation currently showing as the operation between the town fields (as shown in Figure 6). A dialog window is displayed with the various transformation operations available. From the list, select Relationship Lookup
    4. Click the Relationship Lookup transformation and select Show in Properties.
    5. In the Properties tab, select Details.
    6. For the Relationship lookup definition, click New.
    Figure 6:

    Create the relationship
    1. In the “New Relationship Dialog” box, CustomerDetail
    2. Click Next. Select Static Relationship and click Next.
    3. Select Identity relationship and click Finish.
    4. The relationship editor now opens. Click the icon for Add Role.
    5. In the dialog box, select WPSCustomer and click OK.
    6. Repeat this for the WPSDetailCustomer.
    7. Select the WPSCustomer and click the Add Key Attribute icon.
    8. In the “Select Key Attributes” dialog, select id and click OK.
    9. Repeat this for the WPSDetailCustomer.
    10. Next, click the CustomerDetail relationship icon (located just above the Add Role icon), and select the Show in properties view.
    11. In the Properties view, select the Instance Data tab (Figure 7).
    12. You can now populate the relationship with the data that the service will use to map the data.
    Figure 7:
    Test Module:

    1. Return to the Assembly diagram.
    2. Deploy module into Server.
    3. Click the mediation and select Test Component.