Introduced in Feature Pack 2

Customizing the physical layer to include the new tables

In this lesson, you update the physical layer by generating object-relational metadata, and generating physical service data objects (SDOs) based on the previously modified schema. To do so, you use the Data Service Layer wizard.

The Data Service Layer wizard generates object-relational metadata and physical data objects for your schema customization. Physical SDOs represent tables in the WebSphere Commerce schema. Each DataObject type corresponds to a table definition in the schema. Each DataObject property corresponds to a table column or a reference to another DataObject type. These references correspond to the foreign key relationships between the database tables.

For each service module, there are object-relational metadata, which map the physical DataObject to a database table. Custom object-relational metadata is stored in the component configuration extension directories and custom physical SDOs are stored inside the WebSphereCommerceServerExtensionsLogic project.

This wizard performs the following tasks:
  1. Creates an extension configuration folder for the Subscription service module if one does not exist. The directory path is at: WC_eardir\xml\config\com.ibm.commerce.subscription-ext
  2. Generates a custom object-relational metadata file that describes the new custom tables and relationships. In this tutorial, the metadata file describes the new table XSUBSCRSCHTYPE along with the SUBSCRIPTION table.

    This file is at: WC_eardir\xml\config\com.ibm.commerce.subscription-ext\wc-object-relational-metadata.xml.

  3. Generates an SDO Java class and places it in the WebSphereCommerceServerExtensionsLogic project for:
    • The new custom table XSUBSCRSCHTYPE.
    • The modified WebSphere Commerce table SUBSCRIPTION.
    Each table contains one DataObject that represents the tables, columns, and relationships.
  4. Creates a Java utility class to return the physical SDO root class (and its package) for the service module. This root class ensures that all WebSphere Commerce physical SDOs for the service module and any additional customized physical SDOs are available at run time.
  5. Creates an extension service module configuration file that instructs WebSphere Commerce to use the newly created subscription physical SDO class. This file at: WC_eardir\xml\config\com.ibm.commerce.subscription-ext\wc-component.xml.
  6. Creates an extension business object mediator configuration file that configures the business object mediator to include data from the XSUBSCRSCHTYPE table in the user data of a ScheduleInfo noun part.

    This file is at: WC_eardir\xml\config\com.ibm.commerce.subscription-ext\wc-business-object-mediator.xml

Procedure

  1. Open WebSphere Commerce Developer.
Use the Data Service Layer wizard to generate the object-relational metadata and the physical data objects that represents the customized schema.
  1. If your development environment uses an Apache Derby database, ensure that there is no existing connection to it.
    For example, ensure that the WebSphere Commerce server is stopped.
  2. Select File > New > Other > WebSphere Commerce > Data Service Layer.
  3. Click Next.
  4. Select Extend a default WebSphere Commerce service module and click Next.
  5. Enter the following information then click Next:
    • Service module: Select com.ibm.commerce.subscription
    • Extension class prefix: MyCompany
    • Extension Java package name: com.mycompany.commerce.subscription
  6. Select the XSUBSCRSCHTYPE table.
  7. Expand the XSUBSCRSCHTYPE table and make sure that all columns are selected and click Next.
  8. Expand the XSUBSCRSCHTYPE table and make sure that all columns are selected and click Next.
  9. Under UserData, ensure that the SCHTYPE and DAYOFMONTH database columns are set to True. Set the other columns to False if they are set as True by default.
  10. Click Finish.
  11. Edit the WC_eardir\xml\config\com.ibm.commerce.subscription-ext\wc-business-object-mediator.xml file and replace the contents with the following code:
    
    <_config:BusinessObjectMediatorConfiguration
      xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config
      ../xsd/wc-business-object-mediator.xsd">
      <_config:object
           logicalType="com.ibm.commerce.subscription.facade.datatypes.SubscriptionType"
           physicalType="com.mycompany.commerce.subscription.facade.server.entity.datatypes.MyCompanySubscription">
         <_config:property-mapping
           logicalType="com.ibm.commerce.subscription.facade.datatypes.SubscriptionType"
           physicalType="com.mycompany.commerce.subscription.facade.server.entity.datatypes.MyCompanySubscription">
             <_config:child-property-mapping
              relationshipName="XsubscrschtypeForSubscription">
               <_config:userDataProperty
                logicalPropertyName="scheduleType"
                physicalPropertyName="schtype"/>
               <_config:userDataProperty
                logicalPropertyName="dayOfMonth"
                physicalPropertyName="dayofmonth"/>
    
             </_config:child-property-mapping>
                      
        </_config:property-mapping>
    
      </_config:object>
    </_config:BusinessObjectMediatorConfiguration>
    
  12. Save your changes.