In this lesson, you customize
an existing configuration-based data bean mapping to return extra
requisition list data. By default, WebSphere Commerce uses REST calls
for some beans and commands. Configured with mapping profiles, REST
calls map REST input parameters to bean or command setter-methods,
and bean/command getter-methods to REST output parameters. In some
situations, customers might want to use the default REST beans or
commands, but want an augmented set of response data. The configuration-based
command and data bean mapping framework allows customizations where
one REST mapping profile can extend another. For example, RequisitionListDataBean
can be customized to return extra data and to install customizations.
For
more information about the extension strategy that is supported by
the framework, see Creating REST services using the configuration-based controller command and data bean mapping framework.
A
requisition list is a list of items that are used to create future
orders. Users can create requisition lists of items they frequently
order, and use the list to place reorders. The underlying implementation
of a requisition list is an order. The STATUS field
in the ORDERS database table is used to determine whether an order
is a requisition list. Each item on a requisition list is associated
with a catalog entry and has the following attributes: Quantity, Last
update time, Owner, Store, Type: private or shared. The RequisitionDataBean
retrieves the data for the requisition list item, while RequisitionListDataBean
is the object that contains a list of RequisitionDataBeans. RequisitionDataBeans
can retrieve the list of data for the Requisition list items.
Procedure
- In the Enterprise Explorer view, go to .
- Select and open the com.ibm.commerce.order.beans.RequisitionListDataBean.xml file.
Read through the code, find that the existing profile is
called IBM_Store_Summary for the bean. By default, it returns
set of REST outputs, such as comment, description, and lastUpdate.
In the development environment, notice the RequisitionDataBean can
return more data than what WebSphere Commerce supports by default.
For more information, see RequisitionDataBean.
Next, extend the default
profile for the bean to return more data. The profile is supported
by the RequisitionDataBean, which is not a default, as with REST calls
for the bean.
- In the Enterprise Explorer view, go to .
- Copy the com.ibm.commerce.order.beans.RequisitionListDataBean.xml file
from the beanMapping folder to the beanMapping-ext folder.
- Replace the original code to the following code:
<?xml version="1.0" encoding="UTF-8"?>
<bean>
<profiles>
<!-- Profile extends the IBM_Store_Summary profile.
It will look for IBM_Store_Summary first in the extension file, and subsequently the base if not found. -->
<profile name="MyCompany_Store_Summary">
<extends>
<extend profileName="IBM_Store_Summary" />
</extends>
<outputs>
<!-- Extend a nested output element for getRequisitionDataBeans. -->
<output methodName="getRequisitionDataBeans" outputName="resultList">
<output methodName="getTotalTax" outputName="totalTax" />
<output methodName="getEstimatedShipDate" outputName="shipDate" />
<output methodName="getOwner" outputName="Owner" />
</output>
</outputs>
</profile>
</profiles>
</bean>
Note:
- The custom MyCompany_Store_Summary profile extends from the default
IBM_Store_Summary. The custom profile replaces the default IBM_Store_Summary
profile.
- The top outputs are returned by the default profile. The framework
looks in the extension directory. Custom outputs are considered and
merged into the default outputs. Through the REST calls, you can receive
default outputs, and the new outputs.
- Save the file.
- Restart
the WebSphere Commerce Test Server.