Configuring the Business Object Mediator
You can use XML configuration data to configure the Business Object Mediator. This XML can also be generated by the Data Service Layer wizard.
Before you begin
About this task
The schema (both logical and physical) can be extended to add an extension table which has a one-to-one or one-to-many relation to an existing WebSphere Commerce table. This data is represented as name-value pairs in the logical model and is associated with an existing object in the model in the UserData area. In the physical model, this data is represented as a new table that has a foreign key to the base table.
To allow updates, a customer defines a new query to retrieve data from both the default and custom tables. The wc-business-object-mediator.xml needs to be updated to provide the appropriate change mediator with the new custom access profile. An in-depth coverage of the process is demonstrated in Tutorial: Extending a BOD service to manage UserData with the Data Service layer.
getNounPartXPaths
method
to return an array of XPath which the change part mediator handles.
Since the XPath cannot be changed unless the underlying mediator is
in turn also changed, the XPath is defined in the Java code.An example for defining the XPath is as follows:
For a change action <oa:ActionExpression
actionCode="Change" expressionLanguage="_wcf:XPath">/Project[1]/Material[1]oa:ActionExpression
actionCode="Change" expressionLanguage="_wcf:XPath">/Project[1]/Material[1]>
,
add the line <_config:part-mediator-implementation className="com.mycompany.commerce.project.facade.server.services.dataaccess.bom.mediator.ChangeProjectMaterialMediator"
/>
to the wc-business-object-mediator.xml file. Then, define
the XPath private static final String[] XPATH = new String[]
{ "/Material[]" } ;
to the ChangeProjectMaterialMediator.java
file. Note that private static final String[] XPATH = new
String[] { "/" } ;
is present in the ChangeProjectBasePartMediator.java
file.
- It links the logical noun (for example, CatalogEntryType) to your custom physical type (for example MyCompanyCatalogCatalogEntry). These mappings are created to facilitate the flow of custom data stored in the database to the client of the service. The logical properties are exposed as name-value pairs in the UserData element of the business objects.
- It instructs the Business Object Mediator to use the appropriate methods on your physical SDO Java class (for example MyCompanyCatalogCatalogEntry) to add information to the user data element in the logical model (in our example, CatalogEntryType).
- This file also configures the Read and Change mediators for business objects and business object parts.
If you are extending a WebSphere Commerce noun, use this file to change the mapping between the class used to store the logical object and the class that stores the physical object. In particular, you can change the physical class to be a customized physical class. It is this class that contains all of the methods to access your new data. After this, the DSL framework will use your physical object class instead of the default WebSphere Commerce class.
You can use the Data Service Layer wizard to generate this file and the appropriate mappings, or provide the mappings manually.