Step 3 (Optional): Define Associations

SharePoint 2007

Associations link related entities within a line-of-business (LOB) system. For example, an item is associated with a sales order in the AdventureWorks system because a customer makes sales orders. There is a one-to-many relationship between customers and sales orders. An association holds pointers to the parent and child entities as well as a pointer to the business logic that allows a client to get the child entity from the parent entity. The traversal of an association is merely a method call on the LOB system. Associations make it easier for you to create master-detail applications.

For more details on associations in the Business Data Catalog, see Association.

This topic shows you how to define an association between Item and editorial reviews to find the editorial reviews of a particular item. Defining associations is a two-step process:

  1. Define the method in the EditorialReview entity that will return the reviews for a given am Item ASIN.

  2. Define an association between the two entities, Item and EditorialReview, by specifying the method defined in the EditorialReview entity.

NoteNote:

This topic offers a simple example of a one-source, one-destination entity. If you have multiple source entities and only one destination entity, you might expect to define the association logic in the destination entity. However, the Business Data Catalog allows you to define the association logic in any entity in the same LobSystem instance.

  1. Open the AWSECommerceService.xml file from Step 2.

  2. Add the following XML within the <Entities> tag, after the Item entity definition. This XML defines the EditorialReview entity.

        <Entity Name="EditorialReview">
          <Methods>
            <Method Name="ItemLookup">
              <Parameters>
                <Parameter Direction="In"  Name="itemLookup">
                  <TypeDescriptor TypeName="AWSECommerceService.ItemLookup, AWSECommerceService" Name="itemLookup">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="AWSECommerceService.ItemLookupRequest[], AWSECommerceService" Name="Request">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="AWSECommerceService.ItemLookupRequest, AWSECommerceService" Name ="RequestObject">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="System.String[]" Name="ItemId">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="System.String" IdentifierName ="ItemId" IdentifierEntityName="Item" Name="ID">
                                    <DefaultValues>
                                      <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewSpecificFinderInstance">0521004810</DefaultValue>
                                    </DefaultValues>
                                  </TypeDescriptor>
                                </TypeDescriptors>
                              </TypeDescriptor>
                              <TypeDescriptor TypeName="System.String[]"  Name="ResponseGroup">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="System.String" Name="ResponseGroupString">
                                    <DefaultValues>
                                      <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewSpecificFinderInstance">EditorialReview</DefaultValue>
                                      <DefaultValue Type="System.String" MethodInstanceName="EditoralReviewsForItem">EditorialReview</DefaultValue>
                                    </DefaultValues>
                                  </TypeDescriptor>
                                </TypeDescriptors>
                              </TypeDescriptor>
                            </TypeDescriptors>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="SubscriptionId">
                        <DefaultValues>
                          <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewSpecificFinderInstance">EnterYourSubscriptionIdHere</DefaultValue>
                          <DefaultValue Type="System.String" MethodInstanceName="EditoralReviewsForItem">EnterYourSubscriptionIdHere</DefaultValue>
                        </DefaultValues>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="Return"  Name="Response">
                  <TypeDescriptor TypeName="AWSECommerceService.ItemLookupResponse, AWSECommerceService" Name="response">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="AWSECommerceService.Items[], AWSECommerceService" IsCollection="true" Name="Items">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="AWSECommerceService.Items, AWSECommerceService" IsCollection="false" Name="ItemsArray">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="AWSECommerceService.Item[], AWSECommerceService" IsCollection="true" Name="Item">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="AWSECommerceService.Item, AWSECommerceService" IsCollection="false"  Name="ItemArray">
                                    <TypeDescriptors>
                                      <TypeDescriptor TypeName="AWSECommerceService.EditorialReview[], AWSECommerceService" IsCollection ="true"  Name="EditorialReviews">
                                        <TypeDescriptors>
                                          <TypeDescriptor TypeName="AWSECommerceService.EditorialReview, AWSECommerceService" IsCollection="false" Name="EditorialReview">
                                            <TypeDescriptors>
                                              <TypeDescriptor TypeName="System.String" IsCollection="false" Name="Content">
                                                <LocalizedDisplayNames>
                                                  <LocalizedDisplayName LCID="1033">Content</LocalizedDisplayName>
                                                </LocalizedDisplayNames>
                                                <Properties>
                                                  <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                                                </Properties>
                                              </TypeDescriptor>
                                              <TypeDescriptor TypeName="System.String" Name="Source">
                                                <LocalizedDisplayNames>
                                                  <LocalizedDisplayName LCID="1033">Source</LocalizedDisplayName>
                                                </LocalizedDisplayNames>
                                                <Properties>
                                                  <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                                                </Properties>
                                              </TypeDescriptor>
                                            </TypeDescriptors>
                                          </TypeDescriptor>
                                        </TypeDescriptors>
                                      </TypeDescriptor>
                                    </TypeDescriptors>
                                  </TypeDescriptor>
                                </TypeDescriptors>
                              </TypeDescriptor>
                            </TypeDescriptors>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Name="EditorialReviewSpecificFinderInstance" Type="SpecificFinder" ReturnParameterName="Response" ReturnTypeDescriptorName="EditorialReviews"/>
              </MethodInstances>
            </Method>
            <Method Name="ItemSearch">
              <Parameters>
                <Parameter Direction="In"  Name="ItemSearch">
                  <TypeDescriptor TypeName="AWSECommerceService.ItemSearch, AWSECommerceService" Name="itemSearch">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="AWSECommerceService.ItemSearchRequest[], AWSECommerceService" Name="Request">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName ="AWSECommerceService.ItemSearchRequest, AWSECommerceService" Name="RequestObject">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="System.String" Name="SearchIndex">
                                <DefaultValues>
                                  <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewFinderInstance">Books</DefaultValue>
                                </DefaultValues>
                              </TypeDescriptor>
                              <TypeDescriptor TypeName="System.String" Name="Keywords">
                                <DefaultValues>
                                  <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewFinderInstance">Automotive</DefaultValue>
                                </DefaultValues>
                              </TypeDescriptor>
                              <TypeDescriptor TypeName="System.String[]"  Name="ResponseGroup">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="System.String" Name="ResponseGroupString">
                                    <DefaultValues>
                                      <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewFinderInstance">EditorialReview</DefaultValue>
                                    </DefaultValues>
                                  </TypeDescriptor>
                                </TypeDescriptors>
                              </TypeDescriptor>
                            </TypeDescriptors>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                      <TypeDescriptor TypeName="System.String" Name="SubscriptionId">
                        <DefaultValues>
                          <DefaultValue Type="System.String" MethodInstanceName="EditorialReviewFinderInstance">EnterYourSubscriptionIdHere</DefaultValue>
                        </DefaultValues>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
                <Parameter Direction="Return"  Name="Response">
                  <TypeDescriptor TypeName="AWSECommerceService.ItemLookupResponse, AWSECommerceService" Name="response">
                    <TypeDescriptors>
                      <TypeDescriptor TypeName="AWSECommerceService.Items[], AWSECommerceService" IsCollection="true" Name="Items">
                        <TypeDescriptors>
                          <TypeDescriptor TypeName="AWSECommerceService.Items, AWSECommerceService" IsCollection="false" Name="ItemsArray">
                            <TypeDescriptors>
                              <TypeDescriptor TypeName="AWSECommerceService.Item[], AWSECommerceService" IsCollection="true" Name="Item">
                                <TypeDescriptors>
                                  <TypeDescriptor TypeName="AWSECommerceService.Item, AWSECommerceService" IsCollection="false"  Name="ItemArray">
                                    <TypeDescriptors>
                                      <TypeDescriptor TypeName="AWSECommerceService.EditorialReview[], AWSECommerceService" IsCollection ="true"  Name="EditorialReviews">
                                        <TypeDescriptors>
                                          <TypeDescriptor TypeName="AWSECommerceService.EditorialReview, AWSECommerceService" IsCollection="false" Name="EditorialReview">
                                            <TypeDescriptors>
                                              <TypeDescriptor TypeName="System.String" IsCollection="false" Name="Content">
                                                <LocalizedDisplayNames>
                                                  <LocalizedDisplayName LCID="1033">Content</LocalizedDisplayName>
                                                </LocalizedDisplayNames>
                                                <Properties>
                                                  <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                                                </Properties>
                                              </TypeDescriptor>
                                              <TypeDescriptor TypeName="System.String" Name="Source">
                                                <LocalizedDisplayNames>
                                                  <LocalizedDisplayName LCID="1033">Source</LocalizedDisplayName>
                                                </LocalizedDisplayNames>
                                                <Properties>
                                                  <Property Name="DisplayByDefault" Type="System.Boolean">true</Property>
                                                </Properties>
                                              </TypeDescriptor>
                                            </TypeDescriptors>
                                          </TypeDescriptor>
                                        </TypeDescriptors>
                                      </TypeDescriptor>
                                    </TypeDescriptors>
                                  </TypeDescriptor>
                                </TypeDescriptors>
                              </TypeDescriptor>
                            </TypeDescriptors>
                          </TypeDescriptor>
                        </TypeDescriptors>
                      </TypeDescriptor>
                    </TypeDescriptors>
                  </TypeDescriptor>
                </Parameter>
              </Parameters>
              <MethodInstances>
                <MethodInstance Name="EditorialReviewFinderInstance" Type="Finder" ReturnParameterName="Response" ReturnTypeDescriptorName="EditorialReviews"/>
              </MethodInstances>
            </Method>
          </Methods>
        </Entity>
    
  3. Add the following XML after the <Entities> tag to define the association between the Item and EditorialReview entities.

      <Associations>
        <Association AssociationMethodEntityName="EditorialReview" AssociationMethodName="ItemLookup" AssociationMethodReturnParameterName="Response" AssociationMethodReturnTypeDescriptorName="EditorialReviews" Name="EditoralReviewsForItem" >
          <SourceEntity Name="Item"></SourceEntity>
          <DestinationEntity Name ="EditorialReview"/>
        </Association>
      </Associations>
    
  4. Replace the default value for the SubscriptionID parameter with the SubscriptionID you obtained from Amazon in the ItemLookup and ItemSearch methods.

  5. Save the XML file.

  6. Before you add the application definition again, you must delete the AdventureWorksSample application you created in Step 1 from the Business Data Catalog. To delete AdventureWorksSample, follow these steps:

    1. Open SharePoint 3.0 Central Administration.

    2. In the left navigation pane, click the name of your Shared Services Provider (SSP).

    3. In the Business Data Catalog section, click View Applications to view the registered applications.

    4. Click AdventureWorksSample to open the View Application: AdventureWorksSample page.

    5. Finally, click Delete Application in the Application Settings section.

  7. Add the application definition to the Business Data Catalog. For details, see How to: Add an Application Definition to the Business Data Catalog. When you add the application, you might get a warning: "Could not create profile page for Entity EditorialReview. The error is: Profile page creation for the Entity EditorialReview skipped. Entity EditorialReview has no identifiers defined in the SpecificFinder view." You can ignore this warning.

  8. Test the metadata by creating a Business Data List and an Association Web Part. For details, see How to: Test a Business Data Association.

Community Additions

ADD
Show: