Tutorials > Program model > Web services > Create a new WebSphere Commerce BOD service module

< Previous | Next >


Configure the data service layer for the TutorialStore service module

In this lesson we will configure the data service layer for the TutorialStore service module.

The next steps for the customization of the new service module are:

The wc-query-TutorialStore-get.tpl file defines the query templates used to fetch the physical data objects. This template file defines the following symbols:

STOREENT

To represent all columns of the STOREENT table.

STORE

To represent all columns of the STORE table.

STORE_SUMMARY

To represent specific columns of the store table used for the Summary access profile. Note that the OPTCOUNTER column should always be included to enable optimistic concurrency control.

STOREENTDS

To represent all columns of the STOREENTDS table.

STORELANG

To represent all columns of the STORELANG table.

COLS:STOREENT=STOREENT:*
COLS:STORE=STORE:*
COLS:STORE_SUMMARY=STORE:STORE_ID,STATUS,DIRECTORY,STORETYPE,OPTCOUNTER
COLS:STOREENTDS=STOREENTDS:*
COLS:STORELANG=STORELANG:*

The following query example query:

BEGIN_XPATH_TO_SQL_STATEMENT
        <!-- FindByStoreId -->

    name=/BODTutorialStore[StoreIdentifier[(UniqueID=)]]+MyCompany_Details
    base_table=STOREENT
    sql=
        SELECT
                STOREENT.$COLS:STOREENT$,                 STORE.$COLS:STORE$,                 STOREENTDS.$COLS:STOREENTDS$,                 STORELANG.$COLS:STORELANG$
        FROM
                STOREENT
                                JOIN STORE ON (STORE.STORE_ID = STOREENT.STOREENT_ID)
                                LEFT OUTER JOIN STOREENTDS ON (STOREENTDS.STOREENT_ID = STOREENT.STOREENT_ID AND STOREENTDS.LANGUAGE_ID in ($CONTROL:LANGUAGES$))
                                JOIN STORELANG ON (STORELANG.STOREENT_ID = STOREENT.STOREENT_ID)
        WHERE
                STOREENT.STOREENT_ID = ?UniqueID?
END_XPATH_TO_SQL_STATEMENT

The following query example query:

BEGIN_XPATH_TO_SQL_STATEMENT

<!-- FindByStoreId -->

name=/BODTutorialStore[StoreIdentifier[(UniqueID=)]]+MyCompany_Summary
base_table=STOREENT
sql=
    SELECT
            STOREENT.$COLS:STOREENT$,             STORE.$COLS:STORE_SUMMARY$
    FROM
            STOREENT JOIN    STORE ON (STORE.STORE_ID = STOREENT.STOREENT_ID)
    WHERE
          STOREENT.STOREENT_ID = ?UniqueID?

END_XPATH_TO_SQL_STATEMENT

The following diagram shows configuration of the data service layer in the overall customization process:


Procedure

  1. Import the TutorialStore query template files:

    1. In the Enterprise Explorer view, right-click the WC\xml\config\com.mycompany.commerce.bodtutorialstore folder.

    2. Select Import > FileSystem Click Next.

    3. Browse to the temporary location where you unzipped TutorialStore.zip.

    4. Browse to the xml\config\com.mycompany.commerce.bodtutorialstore folder.

    5. Select wc-query-BODTutorialStore-get.tpl and wc-query-BODTutorialStore-update.tpl.

    6. Click Finish. Click Yes to All to overwrite any existing files.

  2. Next, we will define the logical to physical mapping in the wc-business-object-mediator.xml file. This files relates a logical type (noun) to the physical type (physical SDO) that contains its unique ID. For example, the following relates the TutorialStore noun to the STOREENT table physical SDO:

    <object logicalType="com.mycompany.commerce.bodtutorialstore.facade.datatypes.TutorialStoreType" 
    physicalType="com.mycompany.commerce.bodtutorialstore.facade.server.entity.datatypes.Storeent">
    

    To define the logical to physical mapping:

    1. In the project-explorer, open WC\xml\config\com.mycompany.commerce.bodtutorialstore\wc-business-object-mediator.xml.

    2. Replace the sample file with the following:

      <?xml version="1.0" encoding="UTF-8"?>
      <_config:BusinessObjectMediatorConfiguration 
              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" 
              xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
      
        
      <_config:object     logicalType="com.mycompany.commerce.bodtutorialstore.facade.datatypes.TutorialStoreType" physicalType="com.mycompany.commerce.bodtutorialstore.facade.server.entity.datatypes.Storeent">
           
      <_config:mediator 
                              interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectMediator" 
                              className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ReadTutorialStoreMediator">
              
      <_config:part-mediator interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectPartMediator">
                              <_config:part-mediator-implementation 
                                      className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ReadTutorialStoreDescriptionMediator"/>
                              <_config:part-mediator-implementation 
                                      className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ReadTutorialStoreSupportedLanguagesMediator"/>
                              <_config:part-mediator-implementation 
                                      className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ReadTutorialStoreSupportedCurrenciesMediator"/>
               
      </_config:part-mediator>
              
      </_config:mediator>
                <_config:mediator 
                          interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ChangeBusinessObjectMediator" 
                          className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ChangeTutorialStoreMediator">
                   <_config:part-mediator 
                          interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ChangeBusinessObjectPartMediator">
                              <_config:part-mediator-implementation className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ChangeTutorialStoreDescriptionMediator"/>
                                <_config:part-mediator-implementation className="com.mycompany.commerce.bodtutorialstore.facade.server.services.dataaccess.bom.mediator.ChangeTutorialStoreBasePartMediator"/>
               
      </_config:part-mediator>
           
      </_config:mediator>
        
      </_config:object>
      </_config:BusinessObjectMediatorConfiguration>
      

  3. The Data Service Layer provides a customization point to map between internal database codes and external logical values. The <_config:valuemappingservice> element is a customization point within the service module's wc-component.xml file that allows you to configure this conversion. WebSphere Commerce uses 1 to represent an open store, 0 for a closed store, and -1 for a suspended store. This step will configure the Data Service Layer to handle this conversion.

    1. Open WC\xml\config\com.mycompany.commerce.bodtutorialstore\wc-component.xml.

    2. Copy and paste the following inside the <_config:valuemappingservice> element:

          <_config:valuemapping externalName="StoreStateFormat" internalName="StoreStateFormat">
              <_config:valuemap externalValue="Open" internalValue="1"/>
              <_config:valuemap externalValue="Closed" internalValue="0"/>
              <_config:valuemap externalValue="Suspended" internalValue="-1"/>
          </_config:valuemapping>
      

    3. Save the file (Ctrl + S).

  4. Organize the imports for the BODTutorialStore-Server project to resolve any errors reported by WebSphere Commerce Developer:

    1. Open the Java perspective in WebSphere Commerce Developer.

    2. Right-click the BODTutorialStore-Server\EJBModule folder and select Source.

    3. Select Organize Imports.

    4. Save the file.

< Previous | Next >


+

Search Tips   |   Advanced Search