Develop > Business logic layer > Workspaces support for BOD service modules > Change control metadata for business objects in workspaces
Enable workspaces support for a custom table in an existing WebSphere Commerce BOD service module
Adding workspaces support to a for a custom content managed table consists of creating an XML file to identify the table or tables that are managed, and running the existing UpdateWorkspaceSchema script to create the tables in all of the workspaces.
Before you begin
One key aspect of enabling workspaces support is classifying your data as managed content assets or managed operational assets. The distinction between content and operational data is discussed in detail in the Workspaces data model. You need to understand whether the tables to manage using workspaces are content or operational before performing this task.
Procedure
- If it has not already been created, create a resource manager XML file to contain the workspaces customizations. Execute one of the following substeps:
- For a default WebSphere Commerce service module, do not modify the default resource managers file. Create a file with "-ext" in the name:
- workspace_dir\wc\xml\content-management\servicemodulename.resource-managers-ext.xml
- For a custom service module that you created, create the following file:
- workspace_dir\wc\xml\content-management\ servicemodulename.resource-managers.xml
- Open the file in a text or XML editor, and add the following lines to begin the file:
<wc:ResourceContainer xmlns:wc="http://www.ibm.com/xmlns/prod/WebSphereCommerce" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/WebSphereCommerce xsd/wc-resource-managers.xsd"> <wc:Definition id="10001" name="MyServiceModuleNameResourceContainer" className="com.ibm.commerce.context.content.resources.DSLResourceContainer"> </wc:Definition>
The wc:Definition element defines the resource container used by the service module. All BOD service modules use className="com.ibm.commerce.context.content.resources.DSLResourceContainer" as shown in the example. The only value you should change from the sample XML is the id. The value of the id is a unique integer, not previously used by WebSphere Commerce, or other workspace customizations. IBM reserves values ranging from 1 to 9999. Use a value over 10000.
- To add workspace support for a content managed table, add lines similar to the following example to the file:
<wc:ManagedResources> <wc:ManagedResource id="1" name="STORE" resource="STORE" resourceClassName="" resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager" managed="true" resourceKeys="STORE_ID"> <wc:RelatedManagedResource resourceContainer="TutorialStoreResourceContainer" managedResource="STOREENT"/> </wc:ManagedResource> <wc:ManagedResource id="2" name="STOREENT" resource="STOREENT" resourceClassName="" resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager" managed="true" resourceKeys="STOREENT_ID"> </wc:ManagedResource> <wc:ManagedResource id="3" name="STOREENTDS" resource="STOREENTDS" resourceClassName="" resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager" managed="true" resourceKeys="LANGUAGE_ID,STOREENT_ID"> <wc:RelatedManagedResource resourceContainer="TutorialStoreResourceContainer" managedResource="STOREENT"/> </wc:ManagedResource> <wc:ManagedResource id="4" name="STORELANG" resource="STORELANG" resourceClassName="" resourceManagerClassName="com.ibm.commerce.context.content.resources.DSLResourceManager" managed="true" resourceKeys="STOREENT_ID"> <wc:RelatedManagedResource resourceContainer="TutorialStoreResourceContainer" managedResource="STOREENT"/> </wc:ManagedResource>
Notes:
- The resource container is the name of the container that defines the related resource. The resource container is listed in the definition element. For example:
<wc:Definition id="100" name="TutorialStoreResourceContainer" className="com.ibm.commerce.context.content.resources.DSLResourceContainer"/>
- A managed resource element is required for each content managed table.
- The related managed resource element relates one resource to another resource. In the example the STORE, STOREENTDS, and STORELANG tables are related to the STOREENT table. If an entry in the STOREENT table is locked, the related data in the other three tables is also locked.
- The managed resource IDs are unique per resource container. However, for any cases where you are adding managed resources to an existing WebSphere Commerce resource container, it is recommended that you use values greater than 10000, to avoid all possible collisions.
- The resourceClassName attribute is always set to an empty string for Data Service Layer based implementations. This attribute is only used by workspaces in WebSphere Commerce Accelerator.
- The resourceKeys is a comma separated list of the columns that comprise the primary key of the table. For example, resourceKeys="LANGUAGE_ID,STOREENT_ID".
- Add lines similar to the following example for each operational table to add to workspaces:
<wc:OperationalResources> <wc:OperationalResource name="DMACTATTR" resourceClassName="" managed="true" resource="DMACTATTR"/> <wc:OperationalResource name="DMELESTATS" resourceClassName="" managed="true" resource="DMELESTATS"/> <wc:OperationalResource name="DMTRIGSND" resourceClassName="" managed="true" resource="DMTRIGSND"/> <wc:OperationalResource name="DMUSERBHVR" resourceClassName="" managed="true" resource="DMUSERBHVR"/> <wc:OperationalResource name="DMEMSPOTSTATS" resourceClassName="" managed="true" resource="DMEMSPOTSTATS"/> </wc:OperationalResources>
- Close the file with the following lines:
<wc:PublishRequest uniqueTransaction="false"/> </wc:ResourceContainer>
The <wc:PublishRequest> element is used to indicate whether to keep the transactions for this whole file (the resource container) separate from all others when a workspace is published. If set to true, the transactions for this resourceContainer will be published separately. If set to false, transactions will be grouped for all resourceContainers.
- Run ANT target: CM_updateWorkspacesSchema to update workspaces, using the configuration you just provided.
- Enable change control for a noun
You can enable change control for a noun by registering a change control mediator for the noun. No Java coding is required. All change control uses a common change control mediator implementation which is provided for you by default. The data service layer uses the registration information and the change control mediator to validate whether the object can be modified, and to create locks when modifying the object.
- Enable change control for a noun part
In cases where the noun can be divided into parts that can be independently modified, the change control information can also be independent. Part mediators can be registered to change control mediators that manage the noun part.
- Include change control information in the response of a Get service
The Get request access profile determines whether change control information is returned as part of the response. The InsertMoreData command registration point registers a generic implementation that uses the business object mediator to resolve and include change control information.
Related concepts
Workspaces support for BOD service modules
Use authoring access profiles with workspaces
Workspaces support and the Business Context Service
Change control metadata for business objects in workspaces
Related tasks
Call a service with a workspace context from a Java based client or JUnit testcase
Related reference
Change control metadata structure for business objects
Business context service parameters for business object documents