Introduction
REST services are built on top of OAGIS services. Each REST resource is mapped to a Business Object Document (BOD) noun which further follow either the SOI or SOA(BOD) paradigm.
High-Level Changes Required
BOD service can first itself be extended to include the additional attribute in userdata by modifying the BOD related configuration files such as wc-business-object-mediator.xml, wc-object-relational-metadata.xml, wc-component.xml and TPL files and then the additional BOD custom data can be mapped to REST response using rest-resourceName-clientobjects.xml file.
BOD Level Changes-
1. Extend the WCS DB Schema (in case of custom table/column)
2. Run the DSL wizard to generate the supporting BOD configuration files
3. Add the query template files.
4. Add the Access profiles.
4. Validate the changes (can be done through JUNIT)
REST Layer Changes-
1. wc-rest-resourceconfig.xml
2. rest-resourceName-clientobjects.xml
3. Resource Handler
e.g. rest-wishlist-clientobjects.xml is the mapping file used for the wishlist noun stored under the directory- Rest.war/WEB-INF/config/bodMapping
Details
We are considering the BOD pattern in this example so we will pick the wishlist noun to explain the flow and required files to be modified to add additional data
1. wc-rest-resourceconfig.xml is the main file which contains all the REST URLs being utilized for the nouns, This file should be extended if we want to add custom access profile or search profile for the noun-
<Resource name="wishlist">
<GetUri uri="store/{storeId}/wishlist/@self" description="Get wish list data for a logged in user"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/@default" description="Get default wish list for a logged in user"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/{externalId}" description="Get wish list by external id"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/{externalId}/item" description="Get wish list items by external id with paging support" accessProfile="IBM_Store_GiftListItems"/>
</Resource>
2. rest-resourceName-clientobjects.xml
This file contains the mapping between REST data and BOD noun. Any customization to be done in this file requires a copy to be created under the structure-
Rest.war/WEB-INF/config/bodMapping-ext
e.g. below snippet provides support to add custom grgftreg data in userdata section-
<_config:URLParameter name="x_" nounElement="/UserData/UserDataField" key="false" return="true" type="UserData"/>
3. Resource Handler
Resource handler contains the RESTful services to manage the operations on the noun.
e.g. WishlistHandler class provides RESTful services to get and manage a shopper's wish lists.
4. wc-component.xml
It contains properties to configure various REST features.
5. wc-business-object-mediator.xml
It contains the mapping between physical and logical SDOs
e.g. below snippet maps the custom grgftreg fields-
<_config:property-mapping logicalType="com.ibm.commerce.giftcenter.facade.datatypes.GiftListType" physicalType="com.ibm.commerce.giftcenter.facade.server.entity.datatypes.Grgftreg">
<_config:userDataProperty logicalPropertyName="field1" physicalPropertyName="field1"/>
<_config:userDataProperty logicalPropertyName="field2" physicalPropertyName="field2"/>
<_config:userDataProperty logicalPropertyName="field3" physicalPropertyName="field3"/>
<_config:userDataProperty logicalPropertyName="field4" physicalPropertyName="field4"/>
<_config:userDataProperty logicalPropertyName="field5" physicalPropertyName="field5"/>
</_config:property-mapping>
6. wc-object-relational-metadata.xml
It contains the mapping between physical SDOs and the actual database tables.
e.g. below snippet maps the field1 column-
<_config:table name="GRGFTREG" occColumnName="OPTCOUNTER" propertyName="Grgftreg">
<_config:column name="FIELD1" nullable="true" primaryKey="false" propertyName="field1" type="INTEGER"/>
</_config:table>
7. TPL files
In the BOD paradigm, tpl files contains the queries( single step or two step ) to interact with the database.
e.g. the below section contains the second step of the query to be executed based upon the access profile-
BEGIN_PROFILE
name=IBM_Store_GiftListSummaryAndItems
BEGIN_ENTITY
base_table=GRGFTREG
associated_sql_statement=IBM_GR_Summary
associated_sql_statement=IBM_GR_Registrant_Without_Address
associated_sql_statement=IBM_GR_Events
associated_sql_statement=IBM_GR_Items
END_ENTITY
END_PROFILE
REST services are built on top of OAGIS services. Each REST resource is mapped to a Business Object Document (BOD) noun which further follow either the SOI or SOA(BOD) paradigm.
High-Level Changes Required
BOD service can first itself be extended to include the additional attribute in userdata by modifying the BOD related configuration files such as wc-business-object-mediator.xml, wc-object-relational-metadata.xml, wc-component.xml and TPL files and then the additional BOD custom data can be mapped to REST response using rest-resourceName-clientobjects.xml file.
BOD Level Changes-
1. Extend the WCS DB Schema (in case of custom table/column)
2. Run the DSL wizard to generate the supporting BOD configuration files
3. Add the query template files.
4. Add the Access profiles.
4. Validate the changes (can be done through JUNIT)
REST Layer Changes-
1. wc-rest-resourceconfig.xml
2. rest-resourceName-clientobjects.xml
3. Resource Handler
e.g. rest-wishlist-clientobjects.xml is the mapping file used for the wishlist noun stored under the directory- Rest.war/WEB-INF/config/bodMapping
Details
We are considering the BOD pattern in this example so we will pick the wishlist noun to explain the flow and required files to be modified to add additional data
1. wc-rest-resourceconfig.xml is the main file which contains all the REST URLs being utilized for the nouns, This file should be extended if we want to add custom access profile or search profile for the noun-
<Resource name="wishlist">
<GetUri uri="store/{storeId}/wishlist/@self" description="Get wish list data for a logged in user"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/@default" description="Get default wish list for a logged in user"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/{externalId}" description="Get wish list by external id"
accessProfile="IBM_Store_GiftListSummaryAndItems"/>
<GetUri uri="store/{storeId}/wishlist/{externalId}/item" description="Get wish list items by external id with paging support" accessProfile="IBM_Store_GiftListItems"/>
</Resource>
2. rest-resourceName-clientobjects.xml
This file contains the mapping between REST data and BOD noun. Any customization to be done in this file requires a copy to be created under the structure-
Rest.war/WEB-INF/config/bodMapping-ext
e.g. below snippet provides support to add custom grgftreg data in userdata section-
<_config:URLParameter name="x_" nounElement="/UserData/UserDataField" key="false" return="true" type="UserData"/>
3. Resource Handler
Resource handler contains the RESTful services to manage the operations on the noun.
e.g. WishlistHandler class provides RESTful services to get and manage a shopper's wish lists.
4. wc-component.xml
It contains properties to configure various REST features.
5. wc-business-object-mediator.xml
It contains the mapping between physical and logical SDOs
e.g. below snippet maps the custom grgftreg fields-
<_config:property-mapping logicalType="com.ibm.commerce.giftcenter.facade.datatypes.GiftListType" physicalType="com.ibm.commerce.giftcenter.facade.server.entity.datatypes.Grgftreg">
<_config:userDataProperty logicalPropertyName="field1" physicalPropertyName="field1"/>
<_config:userDataProperty logicalPropertyName="field2" physicalPropertyName="field2"/>
<_config:userDataProperty logicalPropertyName="field3" physicalPropertyName="field3"/>
<_config:userDataProperty logicalPropertyName="field4" physicalPropertyName="field4"/>
<_config:userDataProperty logicalPropertyName="field5" physicalPropertyName="field5"/>
</_config:property-mapping>
6. wc-object-relational-metadata.xml
It contains the mapping between physical SDOs and the actual database tables.
e.g. below snippet maps the field1 column-
<_config:table name="GRGFTREG" occColumnName="OPTCOUNTER" propertyName="Grgftreg">
<_config:column name="FIELD1" nullable="true" primaryKey="false" propertyName="field1" type="INTEGER"/>
</_config:table>
7. TPL files
In the BOD paradigm, tpl files contains the queries( single step or two step ) to interact with the database.
e.g. the below section contains the second step of the query to be executed based upon the access profile-
BEGIN_PROFILE
name=IBM_Store_GiftListSummaryAndItems
BEGIN_ENTITY
base_table=GRGFTREG
associated_sql_statement=IBM_GR_Summary
associated_sql_statement=IBM_GR_Registrant_Without_Address
associated_sql_statement=IBM_GR_Events
associated_sql_statement=IBM_GR_Items
END_ENTITY
END_PROFILE