Tutorials > Management Center | Next >
Tutorial: Adding new properties to a WCS service using the data service layer
In this tutorial you customize the Catalog service to support warranty information and care instructions for Catalog Entries. This customization includes...
- Updating the WebSphere Commerce schema to store the new information
- Customizing the Catalog service to include the new information as user data in the CatalogEntry noun.
The WCS BOD programming model separates processing into the business logic layer and the persistence layer. The business logic layer works with logical service data objects (SDOs), which are the Java representation of nouns. The persistence layer creates, reads, updates, or deletes business objects in the WCS database. This separation allows adding new data to impact only the persistence layer.
The CatalogEntry noun uses the UserData element as a data extension point to add new data without changing the logical model. In this tutorial, warranty information is added to the CatalogEntry noun UserData element to demonstrate the addition of language dependent properties. For this tutorial, a warranty applies to a specific catalog entry and consists of a term or number of days the warranty applies and a type, either limited or comprehensive.
The Catalog description noun part supports the attributes element as a data extension point. Attributes provides the same functions as the UserData element. Product care instructions is added to the CatalogEntryDescription noun part attributes element to show the addition of language independent properties. In this tutorial, a care instruction applies to a specific catalog entry and language and consists of a text description of the instruction.
The following example CatalogEntry noun shows the customization of the CatalogEntry UserData element and CatalogEntryDescription attributes element:
<_cat:CatalogEntry catalogEntryTypeCode="ProductBean"> <_cat:CatalogEntryIdentifier> <_wcf:UniqueID>10251</_wcf:UniqueID> <_wcf:ExternalIdentifier ownerID="7000000000000000101"> <_wcf:PartNumber>FULO-01</_wcf:PartNumber> </_wcf:ExternalIdentifier> </_cat:CatalogEntryIdentifier> <_cat:Description language="-1"> <_cat:Name>White Fabric Roll Arm Chaise</_cat:Name> <_cat:Thumbnail>images/catalog/FULO_01_sm.jpg</_cat:Thumbnail> <_cat:FullImage>images/catalog/FULO_01.jpg</_cat:FullImage> <_cat:ShortDescription>Plumply padded for the ultimate comfort.</_cat:ShortDescription> <_cat:Attributes name="catentryId">10251</_cat:Attributes> <_cat:Attributes name="languageId">-1</_cat:Attributes> <_cat:Attributes name="careinstruction">Warranty description for the chaise.</_cat:Attributes> </_cat:Description> <_wcf:UserData> <_wcf:UserDataField name="warterm">30</_wcf:UserDataField> <_wcf:UserDataField name="wartype">LIMITED</_wcf:UserDataField> </_wcf:UserData> </_cat:CatalogEntry>
The persistence layer is customized according touch points identified and numbered in the following diagram:
The numbered boxes in the diagram correspond to the following tasks:
- Update the WCS database with new tables and relationships.
- Generate custom object-relational metadata that describes the new tables and relationships. In this tutorial, the custom metadata describes the new tables added to store warranty and care instruction information.
- Generate static service data objects (SDO) that provide a Java representation of the newly added tables. The term static SDOs and physical data objects are used interchangeably.
- Configure the logical data object to physical data object mapping. In this tutorial we will configure the business object mediator to populate warranty information as UserData in the CatalogEntry noun and care instruction information as attributes to the CatalogDescription noun part.
- Create a custom query template file to map an XPath expression and access profile to SQL. This template file:
- Defines a SQL template statement that fetches data from the new tables.
- Associates a new access profile to the new SQL template statement.
- Associates a XPath expression to the new SQL template statement.
Audience
This tutorial is intended for WCS developers responsible for creating and customizing WCS BOD services.
System requirements
Before beginning this tutorial ensure that you have fulfilled the following prerequisites:
Workspaces are not supported when completing this tutorial.
Prerequisites
To complete this tutorial you should be familiar with the following terms and concepts:
- Web services
- XML
- WCS services
- Relational databases
- SQL
You must also publish the consumer direct sample store.
Lessons in this tutorial
- Customize the WCS schema
In this step we will customize the physical layer by adding tables to contain store warranty and care instruction information to the WCS schema.
- Customize the physical layer to include the new information
In this step we will customize the physical layer by modifying the WCS schema, generating object-relational metadata, and generating physical service data objects (SDOs).To do so, you will use a tool called the Data Service Layer wizard.
- Add query templates to include the new information
The Catalog Service Module needs to be configured to update warranty and care instruction user data. In this step we will add query template files that will help retrieve our custom warranty information. Query template files store the SQL and access profile definitions for a service module, isolating it from the business logic layer completely.
- Create an access control policy to secure the new information
The previous step created a new access profile, MyCompany_All. By default, only the users with a site administrator role will have access to this new data. In this step we will update the Catalog service access control policy to state that all users have access to view this data.
- Validate the Catalog customization with JUnit
This step demonstrates how to test the customization using JUnit. This unit tests assumes a starter store with a store ID of 10101 and a catalog ID of 10101 has been published to the WebSphere Commerce Development environment.