
Enabling viewing custom object versions on the UI
Before you begin
- Ensure that the custom tables have already been added to the version schema.
- Review the following topic for additional information about viewing version details: Viewing version details.
Procedure
- Create a serialization JSP file to transform the server
version objects into XML that the client understands.Follow the steps in Creating and registering a serialization JSP file to enable viewing version objects.
- Update your custom query template file.To view the version information, you must update the query template file. The query template file defines SQL queries that retrieve data from the server.
When versions are displayed, some of the data must be retrieved from the version schema and other data must be retrieved from the base schema. You must determine whether you need to write version-specific queries. For more information about query template SQL generation, see Viewing version details.
Here's an example of a custom query template file that retrieves different versions for the Recipe object using the version SQL generation.BEGIN_XPATH_TO_SQL_STATEMENT name=/Project[ProjectIdentifier[(UniqueID=)]] base_table=XPROJECT param=versionable sql= SELECT XPROJECT.$COLS:XPROJECT_ID$ FROM XPROJECT WHERE XPROJECT.XPROJECT_ID IN (?UniqueID?) END_XPATH_TO_SQL_STATEMENT
- Configure existing services to retrieve version-related
information.The WebSphere Commerce framework shares services to retrieve information for the business objects and its versions. For example, a product object uses the following
GetChildrenService
in ProductPrimaryObjectDefinition.def to retrieve defining attributes:<GetChildrenService objectTypes="CatalogEntryDefiningAttribute" url="/cmc/GetCatalogEntryChildren-DefiningAttributes"> <ServiceParam name="storeId"/> <ServiceParam name="defaultLanguageId"/> </GetChildrenService>
If you want to version defining attributes that belong to this Product, you can configure this service to retrieve defining attributes for the versions of this product or the product itself as follows:- Identify the corresponding
GetChildrenService
as shown in the primary object definition of this business object. - Use the Struts configuration file to identify the JSP file that
provides this service:
<action path="/GetCatalogEntryChildren-DefiningAttributes" forward="/jsp/commerce/catalog/restricted/GetCatalogEntryDefiningAttributes.jsp" />
- In the GetCatalogEntryDefiningAttributes.jsp file,
add the following context data to the
getData
service:
The complete<wcf:contextData name="versionId" data="${param.objectVersionId}"/>
getData
service code:<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]" var="catalogEntry" expressionBuilder="getCatalogEntryDefiningAttributesByID"> <wcf:contextData name="storeId" data="${param.storeId}"/> <wcf:contextData name="versionId" data="${param.objectVersionId}"/> <wcf:param name="catEntryId" value="${param.parentId}"/> <wcf:param name="dataLanguageIds" value="${param.dataLanguageIds}"/> </wcf:getData>
When a content version service is invoked, the
versionId
context data indicates to the getData service on the server side whether the request is for the business object or for the business object version. For example, when you open a product, the getData service is invoked to retrieve defining attribute information. In this case, an empty value is assigned to theversionId
parameter; because this is not a product version. However, if you open a product version, a non-empty value is assigned to theversionId
parameter, and the getData service uses this ID to return the defining attribute information for the particular product version. - If you are versioning other child objects of this primary object,
repeat the preceding steps for the corresponding
GetChildrenService
. - If you decide to version a particular relationship that belongs
to a business object, for example, the parent category of a product,
you must configure the corresponding
GetReferencesService
in ProductPrimaryObjectDefinition.def:<GetReferencesService url="/cmc/GetCatalogEntryParent-MasterCatalogCatalogGroup"> <ServiceParam name="storeId"/> <ServiceParam name="masterCatalogId"/> <ServiceParam name="catentryId" propertyName="catentryId"/> <ServiceParam name="childType" value="ChildProduct"/> </GetReferencesService>
- Use the Struts configuration file to identify the JSP file that
provides this service:
<action path="/GetCatalogEntryParent-MasterCatalogCatalogGroup" forward="/jsp/commerce/catalog/restricted/GetCatalogEntryParent-ReferenceMasterCatalogGroup.jsp" />
- In the GetCatalogEntryParent-ReferenceMasterCatalogGroup.jsp file,
add the following context data to the
getData
service:
The complete<wcf:contextData name="versionId" data="${param.objectVersionId}"/>
getData
service code:<wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType" var="catalogEntry" expressionBuilder="getCatalogEntrySummaryByID" varShowVerb="showCatalogEntryVerb"> <wcf:contextData name="storeId" data="${param.storeId}"/> <wcf:contextData name="catalogId" data="${param.masterCatalogId}"/> <wcf:contextData name="versionId" data="${param.objectVersionId}"/> <wcf:param name="catEntryId" value="${param.catentryId}"/> </wcf:getData>
- Repeat the preceding steps to configure versioning of the other relationships of this business object.
- Include the
versionId
information for the RefreshService so that when users want to refresh the versioned object, the versioned information is retrieved again. For example, for the Product object, locate theRefreshService
in theCatalogEntryPrimaryObjectDefinition.def
file.<RefreshService url="/cmc/GetCatalogEntry"> <ServiceParam name="storeId"/> <ServiceParam name="catalogId" parentProperty="true" parentType="CatalogAlias" propertyName="catalogId"/> <ServiceParam name="catentryId" propertyName="catentryId"/> <ServiceParam checkObjectDefinition="true" name="objectType" propertyName="objectType"/> </RefreshService>
- Use the Struts configuration file to identify the JSP file that
provides this service:
<action path="/GetCatalogEntry" forward="/jsp/commerce/catalog/restricted/GetCatalogEntry.jsp" />
- In the GetCatalogEntry.jsp file, add a new
context data entry as follows:
<wcf:contextData name="versionId" data="${param.objectVersionId}"/> So the complete getData tag is: <wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]" var="catalogEntries" expressionBuilder="getCatalogEntryDetailsByIDs" varShowVerb="showVerb" recordSetStartNumber="${param.recordSetStartNumber}" recordSetReferenceId="${param.recordSetReferenceId}" maxItems="${param.maxItems}"> <wcf:contextData name="storeId" data="${param.storeId}"/> <wcf:contextData name="catalogId" data="${param.catalogId}"/> <wcf:contextData name="versionId" data="${param.objectVersionId}"/> <wcf:param name="dataLanguageIds" value="${param.dataLanguageIds}"/> <wcf:param name="UniqueID" value="${param.catentryId}"/> </wcf:getData>
- Identify the corresponding
- Update the command registry for the custom access profile
to register the insert more version command implementation.When viewing versioned objects, the Management Center needs to know information about the version such as the version ID. To retrieve and include this information in the noun, you must register an "InsertMore" command.Here's the example SQL statement to register
MyCompany_All
custom access profile for the preceding Warranty example:insert into cmdreg (storeent_id, interfacename, classname, target) values (0, 'com.ibm.commerce.catalog.facade.server.commands.InsertMoreCatalogEntryDataCmd+MyCompany_All.10', 'com.ibm.commerce.foundation.server.version.command.InsertMoreNounVersionMetaDataCmdImpl', 'Local');
The
InsertMoreNounVersionMetaDataCmdImpl
looks up the version information for the CatalogEntry noun and adds the version information to the response.