Viewing version details

To enable viewing different version details on the UI, you modify the serialization JSP file that retrieves data for the versions, and you also update the query template file to make the SQL queries versionable to retrieve the different version information.

In the JSP file, you modify the <wcf:getData> tag to add the context data as shown:
<wcf:contextData name="versionId" data="${param.objectVersionId}"/>
The wcf:getData tag is used to retrieve business object information. For more information about how to locate the wcf:getData tag to modify, see the instructions in step 4 of the following page: Enabling viewing custom object versions on the UI.

In the query template file, you either add a versionId parameter to the query or define a version-specific query. When version objects are displayed, some of the data must be retrieved from the version schema (data that is versioned) and other data must be retrieved from the base schema (data that is not versioned). The system can automatically adjust the queries of certain types. For other types of queries, you must write a version-specific query.

Limitations of view version SQL generation

  • SQL Subselect statements are not supported.
  • If a table is versionable, all occurrences of that table in a query must come from the version schema. For example, if there is a query with two versionable tables (CATENTRY and CATENTDESC), the version SQL generation either adds the version schema prefix to both tables (for version requests) or to neither table (not version request). This behavior occurs because version SQL generation does not allow select data from the base CATENTRY table and from the version CATENTDESC table in the same query. To select data from both tables, a version-specific query is required.

Content versioning query template SQL generation

Query templates that support version SQL generation is marked with a "param=versionable" in the query template file. To retrieve the version object, the existing Get<Noun> service is used and a versionId parameter is passed in the business context area of the request. When the server detects a version request, it modifies the SQL defined in the query template to include the versionId, and select data from tables in the version schema as defined in the wc-content-version.xml configuration file.

For example, to retrieve a version of CatalogGroup 10201, a GetCatalogGroup request is sent with the specified versionId in the business context. View version requests support only one object, that is, a request can return only one version of CatalogGroup 10201. It cannot return multiple versions of the CatalogGroup 10201. Also, view version requests cannot return multiple versions for multiple objects.

Consider the following CatalogGroup associated query marked as versionable:

BEGIN_ASSOCIATION_SQL_STATEMENT
  name=IBM_RootCatalogGroupWithDescriptionWithTopCatGroup
  base_table=CATGROUP
  additional_entity_objects=true
  param=versionable	
  sql= SELECT CATGROUP.$COLS:CATGROUP$, CATGRPDESC.$COLS:CATGRPDESC$, CATTOGRP.$COLS:CATTOGRP$
       FROM CATGROUP LEFT OUTER JOIN CATGRPDESC ON (CATGROUP.CATGROUP_ID = CATGRPDESC.CATGROUP_ID 
       AND CATGRPDESC.LANGUAGE_ID IN ($CONTROL:LANGUAGES$)) 
       LEFT OUTER JOIN CATTOGRP ON (CATGROUP.CATGROUP_ID = CATTOGRP.CATGROUP_ID 
       AND (CATTOGRP.CATALOG_ID = $CTX:CATALOG_ID$ OR CATTOGRP.CATALOG_ID_LINK IS NULL))
       WHERE CATGROUP.CATGROUP_ID IN ($ENTITY_PKS$)
       END_ASSOCIATION_SQL_STATEMENT
The following events occur when a query is transformed into a version query:
  • Any versionable tables that are not joined are replaced by the table from the version schema. For example, the CATGROUP table is versionable and is replaced by VCW_DEMO.CATGROUP.
  • Any versionable tables that are joined are replaced with an alias that selects data from the versionable table and the filters the data by the specified versionId. For example, the CATGRPDESC table is versionable and the statement:
    
    LEFT OUTER JOIN CATGRPDESC ON  (CATGROUP.CATGROUP_ID = CATGRPDESC.CATGROUP_ID 
    AND CATGRPDESC.LANGUAGE_ID IN ($CONTROL:LANGUAGES$))
    Is replaced by:
    
    LEFT OUTER JOIN (SELECT * FROM VCW_DEMO.CATGRPDESC WHERE VCW_DEMO.CATGRPDESC.CMVERSNINFO_ID = versionId) T0 
    ON (VCW_DEMO.CATGROUP.CATGROUP_ID = T0.CATGROUP_ID AND T0.LANGUAGE_ID IN ($CONTROL:LANGUAGES$))
  • Aliases that are created in the preceding step are substituted back into the query. For example, the alias T0 is created for the CATGRPDESC table in the preceding example and the following statement.
    
    SELECT CATGROUP.$COLS:CATGROUP$, CATGRPDESC.$COLS:CATGRPDESC$, CATTOGRP.$COLS:CATTOGRP$
    
    This statement is then transformed to be the following statement:
    
    SELECT VCW_DEMO.CATGROUP.$COLS:CATGROUP$, T0.$COLS:CATGRPDESC$, CATTOGRP.$COLS:CATTOGRP$
    
    The final transformed query can resemble the following query:
    
    FROM VCW_DEMO.CATGROUP 
      LEFT OUTER JOIN (SELECT * FROM VCW_DEMO.CATGRPDESC WHERE VCW_DEMO.CATGRPDESC.CMVERSNINFO_ID = versionId) T0 
      ON (VCW_DEMO.CATGROUP.CATGROUP_ID = T0.CATGROUP_ID AND T0.LANGUAGE_ID IN ($CONTROL:LANGUAGES$))
      LEFT OUTER JOIN (SELECT * FROM VCW_DEMO.CATTOGRP WHERE VCW_DEMO.CATTOGRP.CMVERSNINFO_ID = versionId) T1 
      ON (VCW_DEMO.CATGROUP.CATGROUP_ID = T1.CATGROUP_ID AND (T1.CATALOG_ID = $CTX:CATALOG_ID$ OR T1.CATALOG_ID_LINK IS NULL)) 
      WHERE VCW_DEMO.CATGROUP.CATGROUP_ID IN ($ENTITY_PKS$) AND VCW_DEMO.CATRGROUP.CMVERSNINFO_ID = versionId

Version-specific queries

Alternatively, version-specific queries can be constructed by using the $VERSION$ and $VERSION_ID$ tags in the query template. Data service layer (DSL) replaces the $VERSION$ tag with version schema name (such as VCW_DEMO). DSL replaces the $VERSION_ID$ tab with the versionId parameter from the business context area of the request. Consider the following CatalogEntry associated query that uses $VERSION$ and $VERSION_ID$ tags:

BEGIN_XPATH_TO_SQL_STATEMENT
  name=/CatalogEntry[CatalogEntryIdentifier[(UniqueID=)]]+MyCompany_Admin_Details_Version
  base_table=CATENTRY
  className=com.ibm.commerce.catalog.facade.server.services.dataaccess.db.jdbc.EntitledCatalogEntriesSQLComposer 
  param=accessProfile_IBM_Store
  param=includeBrowseable_true
  param=psMark_AndPSAgreements	
  param=versionable
  sql= SELECT $VERSION$.CATENTRY.$COLS:CATENTRY$, $VERSION$.CATENTDESC.$COLS:CATENTDESC$
       FROM $VERSION$.CATENTRY 
       LEFT JOIN $VERSION$.CATENTDESC ON ($VERSION$.CATENTRY.CMVERSNINFO_ID = $VERSION$.CATENTDESC.CMVERSNINFO_ID 
       AND $VERSION$.CATENTDESC.LANGUAGE_ID IN ($CONTROL:LANGUAGES$)) 
       WHERE $VERSION$.CATENTRY.CATENTRY_ID IN (?UniqueID?) AND $VERSION$.CATENTRY.CMVERSNINFO_ID = $VERSION_ID$
       END_XPATH_TO_SQL_STATEMENT
SQL statement after substitution of version parameters:

SELECT VCW_DEMO.CATENTRY.$COLS:CATENTRY$, VCW_DEMO.CATENTDESC.$COLS:CATENTDESC$
  FROM VCW_DEMO.CATENTRY 
  LEFT JOIN VCW_DEMO.CATENTDESC ON (VCW_DEMO.CATENTRY.CMVERSNINFO_ID = VCW_DMEO.CATENTDESC.CMVERSNINFO_ID 
  AND VCW_DMEO.CATENTDESC.LANGUAGE_ID IN ($CONTROL:LANGUAGES$)) 
  WHERE VCW_DEMO.CATENTRY.CATENTRY_ID IN (?UniqueID?) AND VCW_DEMO.CATENTRY.CMVERSNINFO_ID = 10501