Customizing the physical layer to include the new information

In this lesson, you customize the physical layer by modifying the WebSphere Commerce schema, generate object-relational metadata, and generate physical service data objects (SDOs). To do so, you use a tool that is called the Data Service Layer wizard.

About this task

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

For each service module, there is object-relational metadata that contains the information to relate the physical data object 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:
  • Creates an extension configuration folder for the catalog service module if one does not exist. The directory path that you create is workspace_dir\wc\xml\config\com.ibm.commerce.catalog-ext.
  • Generates a custom object-relational metadata file that describes the new custom tables and relationships. In this tutorial, the metadata file describes the two new tables, XWARRANTY and XCAREINSTRUCTION, along with the three new relationships between tables:
    • XWARRANTY and CATENTRY
    • XCAREINSTRUCTION and CATENTRY
    • XCAREINSTRUCTION and CATENTDESC
    This file location is workspace_dir\wc\xml\config\com.ibm.commerce.catalog-ext\wc-object-relational-metadata.xml.
    Note: The wc-object-relational-metadata.xml file maps the database tables and columns to physical SDOs.
    For example, the following snippet of the XWARRANTY configuration as generated by the DSL wizard in this tutorial:
    
    <_config:table name="XWARRANTY" occColumnName="OPTCOUNTER" propertyName="Xwarranty">
        <_config:column name="CATENTRY_ID" nullable="false" primaryKey="true" propertyName="catentry_id" type="BIGINT"/>
    
    Where the column CATENTRY_ID is mapped to the field catentry_id in the XWarranty Java class.
  • Generates an SDO Java class and places it in the WebSphereCommerceServerExtensionsLogic project for:
    • Each new custom table (XWARRANTY and XCAREINSTRUCTION).
    • Each modified WebSphere Commerce table (CATENTRY and CATENTDESC were modified by adding new relationships to the custom tables).
    Physical SDOs are service data objects that represent tables in WebSphere Commerce. For each table, there is one data object, which represents the tables, columns, and relationships.
  • Creates a utility Java 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 physical SDOs for the customization, are available at run time.
  • Creates an extension service module configuration file that instructs WebSphere Commerce to use the newly created catalog physical SDO class in workspace_dir\wc\xml\config\com.ibm.commerce.catalog-ext\wc-component.xml.
  • Creates an extension business object mediator configuration file. This file configures the business object mediator to include data from the XWARRANTY and XCAREINSTRUCTION tables in the user data of a CatalogEntry noun. This file location is workspace_dir\wc\xml\config\com.ibm.commerce.catalog-ext\wc-business-object-mediator.xml.

Procedure

Use the Data Service Layer wizard to generate object-relational metadata and physical data objects that represent the customized schema.
  1. Apache Derby If your development environment uses an Apache Derby database, ensure that there is no existing connection to the database.
    For example, ensure that the WebSphere Commerce server is stopped.
  2. Open IBM WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  3. In the Enteprise Explorer view, expand File > New > Other > WebSphere Commerce.
  4. Select Data Service Layer and click Next.
  5. Select Extend a default WebSphere Commerce service module and click Next.
  6. In the Service Module Information configuration, enter the following information:
    • Service module: Select com.ibm.commerce.catalog
    • Extension class prefix: MyCompany
    • Extension Java package name: com.mycompany.commerce.catalog
  7. Click Next.
  8. Select the XCAREINSTRUCTION and XWARRANTY tables and click Next.
  9. In the Metadata Editing configuration, edit the UserData column settings. Ensure that the WARTERM, WARTYPE, and CAREINSTRUCTION database columns are set to true. Set all other columns to False.

    Image showing the metadata editing settings.
  10. Click Finish.

Results

If the code generated by the Data Service Layer produces an error, such as CatalogEntityPackage cannot be resolved. Select Project > Clean to resolve the issue.