Configuring the data service layer for the Project service module
In this lesson, you configure the data service layer for the Project service module, through XML to provide the necessary mappings.
About this task
- Define four query templates:
- wc-query-Project-get.tpl
- A query template that maps each get request XPath statement and access profile to a SQL template query.
- wc-query-Project-update.tpl
- A query template file that maps each change request XPath statement to a SQL template query.
- wc-query-ProjectCollection-get.tpl
- A query template file that maps each get request XPath statement and access profile to a SQL template query.
- wc-query-ProjectCollection-update.tpl
- A query template file that maps each change request XPath statement to a SQL template query.
- Define the logical to physical SDO mapping:
- Defines the wc-business-object-mediator.xml file to relate logical nouns to physical data objects.
- Update the Project service configuration (wc-component.xml) to:
- Use the DSL value-mapping to map between internal database codes and external logical values.
Note: For more information, see Service module configuration.
In this tutorial, all the query template files and configuration files are provided. You can import the files directly.
The wc-query-Project-get.tpl file
defines the query templates used to retrieve the physical data objects.
This template file defines the following symbols:
<!-- XPROJECT table -->
COLS:XPROJECT=XPROJECT:*
COLS:XPROJECT_ID=XPROJECT:XPROJECT_ID
<!-- XPRJDES table -->
COLS:XPRJDES=XPRJDES:*
<!-- XPRJMTR table -->
COLS:XPRJMTR=XPRJMTR:*
<!-- XPRJMTRDES table -->
COLS:XPRJMTRDES=XPRJMTRDES:*
<!-- XPRJMTRCATREL table -->
COLS:XPRJMTRCATREL=XPRJMTRCATREL:*
<!-- XPRJINS table -->
COLS:XPRJINS=XPRJINS:*
<!-- XPRJINSDES table -->
COLS:XPRJINSDES=XPRJINSDES:*
<!-- XPRJPRJCOLREL table -->
COLS:XPRJPRJCOLREL=XPRJPRJCOLREL:*
<!-- XPRJCOL table -->
COLS:XPRJCOL=XPRJCOL:*
<!-- XPRJCOLDES table -->
COLS:XPRJCOLDES=XPRJCOLDES:*
<!-- XPRJCATREL table -->
COLS:XPRJCATREL=XPRJCATREL:*
The following example query:
<!-- ============================================================= -->
<!-- This SQL template will return the elements of the Project -->
<!-- noun(s) given project identifier(s) -->
<!-- The access profiles that apply to this SQL are: -->
<!-- MyCompany_Summary project profiles -->
<!-- @param UniqueID - The project identifier(s) . -->
<!-- ============================================================= -->
BEGIN_XPATH_TO_SQL_STATEMENT
name=/Project[ProjectIdentifier[(UniqueID=)]]+MyCompany_Admin_Summary
base_table=XPROJECT
sql=
SELECT
XPROJECT.$COLS:XPROJECT$,
XPRJDES.$COLS:XPRJDES$
FROM
XPROJECT
LEFT OUTER JOIN XPRJDES ON (XPROJECT.XPROJECT_ID = XPRJDES.XPROJECT_ID AND XPRJDES.LANGUAGE_ID IN ($CONTROL:LANGUAGES$) )
WHERE
XPROJECT.XPROJECT_ID IN (?UniqueID?)
END_XPATH_TO_SQL_STATEMENT
Next, you define the logical to physical mapping in the wc-business-object-mediator.xml file. This file relates a logical type (noun) to the physical type (physical SDO) that contains its unique ID. For example, the following code relates the Project noun to the XPROJECT table physical SDO:
<object
logicalType="com.mycompany.commerce.Project.facade.datatypes.ProjectType"
physicalType="com.mycompany.commerce.Project.facade.server.entity.datatypes.Xproject">
The following code samples shows you how to configure
the read and change mediators. The read mediator is shown in the following
sample:
<_config:mediator
interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectMediator"
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectMediator">
<_config:part-mediator
interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ReadBusinessObjectPartMediator">
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectDescriptionPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectMaterialPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectInstructionPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectCollectionRelPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ReadProjectToolPartMediator" />
</_config:part-mediator>
</_config:mediator>
The configuration of the change mediator is shown
in the following sample code:
<_config:mediator
interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ChangeBusinessObjectMediator"
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectMediator">
<_config:part-mediator
interfaceName="com.ibm.commerce.foundation.server.services.dataaccess.bom.mediator.ChangeBusinessObjectPartMediator">
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectBasePartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectDescriptionPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectMaterialPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectInstructionPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectToolPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectCollectionRelPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectMaterialDescriptionPartMediator" />
<_config:part-mediator-implementation
className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectInstructionDescriptionPartMediator" />
</_config:part-mediator>
</_config:mediator>
The configuration in the wc-component.xml file is shown in the following sample, which uses DSL value-mapping to map between the database and external logical values:
<_config:dataservice dataMediatorType="JDBC"
metadataClass="com.mycompany.commerce.project.facade.server.metadata.ProjectMetadata">
<!-- Mapping for search -->
<_config:mapping>
<_config:key name="Project" />
<_config:basetable name="XPROJECT" useAllColumns="true">
<_config:columns name="PRJNAME"
propertyName="ProjectIdentifier/ExternalIdentifier/Name" />
</_config:basetable>
</_config:mapping>
<_config:mapping>
<_config:key name="ProjectCollection" />
<_config:basetable name="XPRJCOL" useAllColumns="true">
<_config:columns name="PRJCOLNAME"
propertyName="ProjectCollectionIdentifier/ExternalIdentifier/Name" />
</_config:basetable>
</_config:mapping>
<_config:store-relationship key="recipe"
value="com.mycompany.commerce.recipe" />
</_config:dataservice>
Import the configuration files: Procedure
- In the Enterprise Explorer view, expand WC/xml/config.
- Right-click com.mycompany.commerce.project; click Import.
- Expand General select File System, then click Next.
- Browse to the temporary location where you unzipped RecipeServices.zip.
- Browse to the config\com.mycompany.commerce.project folder; select the folder, then click Ok.
- Select all files; click Finish.
- Click Yes to All to overwrite any existing files.