Business Object Document Get processing pattern
The Business Object Document Get processing pattern describes the design pattern used to perform searching for and retrieving of data. Processing the Get request involves a Get controller which will delegate to task commands:
- A Fetch command that pulls the data for the requested business objects from the data service layer and transforms it into the OAGIS logical structure
- An optional InsertMoreData task command used to augment the objects retrieved by the fetch, for example to add computed values or aggregate with content from an alternate data source
Note: More than one InsertMoreData task command is supported per Get request.
The GetNoun command is a controller command that will parse the expression from the Get request, perform common validation such as access control, and then delegate to the fetch command to retrieve the list of nouns that match the expression. The fetch command returns the list of nouns that match the search expression and the Show verb that represents the returned list of nouns. The GetNoun command will use an XPath selector to choose the appropriate registered fetch command implementation to retrieve the data. Although the default implementation of the GetNoun command is used in most cases, the extension allows for additional business logic to be added for particular search expressions.
When you register a command in the CMDREG table, we can append an additional string, appended to the interface name, to help WebSphere Commerce choose the appropriate implementation Fetch or InsertMoreData command. This additional string is set to be the XPath selector, when registering a Fetch command, and set to be the name of an access profile, when registering the InsertMoreData implementation. An example of a Get request is seen below. The access profile is IBM_Admin_Details. The XPath selector is /CatalogEntry[CatalogEntryIdentifier[]]. So the registered fetch implementation for this XPath would be registered with "+/CatalogEntry[CatalogEntryIdentifier[]]" appended to the INTERFACENAME column value in the CMDREG table. The registered InsertMoreData command would be registered with "+IBM_Admin_Details" appended to the INTERFACENAME.
<_cat:GetCatalogEntry xmlns:_cat="http://www.ibm.com/xmlns/prod/commerce/9/catalog" xmlns:_wcf="http://www.ibm.com/xmlns/prod/commerce/9/foundation" xmlns:oa="http://www.openapplications.org/oagis/9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <oa:ApplicationArea xsi:type="_wcf:ApplicationAreaType"> <oa:CreationDateTime>2007-01-25T16:44:16.004Z</oa:CreationDateTime> <oa:BODID>341d6660-acbd-11db-a3a8-832d45b924b0</oa:BODID> <_wcf:BusinessContext> <_wcf:ContextData name="storeId">511</_wcf:ContextData> </_wcf:BusinessContext> </oa:ApplicationArea> <_cat:DataArea> <oa:Get> <oa:Expression expressionLanguage="_wcf:XPath">{wcf.ap=IBM_Admin_Details}/CatalogEntry[CatalogEntryIdentifier[UniqueID='51100000117']]</oa:Expression> </oa:Get> </_cat:DataArea> </_cat:GetCatalogEntry>
For access profiles to have additional information based on business logic or from an external system, the GetNoun controller can instantiate an instance of an InsertMoreData task command for a particular access profile to populate more data. The InsertMoreData command is optional and should be used when the information cannot be retrieved from the data service layer. Because multiple InsertMore commands can be registered for the same access profile, the .index notation permits more than one InsertMore command to run and the order is based on the registered index. In the example below, an InsertMore command is registered with an index of 0, appended to the access profile as IBM_Admin_Details.0:
insert into cmdreg (storeent_id, interfacename, classname, target) values (0, 'com.ibm.commerce.catalog.facade.server.commands.InsertMoreCatalogEntryDataCmd+IBM_Admin_Details.0', 'com.ibm.commerce.foundation.server.command.bod.bom.InsertMoreNounChangeControlMetaDataCmdImpl', 'Local');
The AbstractFetchNounFromBusinessObjectMediatorCmdImpl will use the Business Object Mediator (BOM) to process the request. To simplify the implementation of a Get service, IBM recommends that Fetch command implementations would extend this class. Supported XPath expressions can be configured using the data service configuration instead of code. The Fetch implementation passes the search expression extracted from the Get verb to the BOM. This search expression includes the XPath, access profile and paging information. The BOM in turn will use the business object mediator and data service layer to retrieve the data and convert it to its logical representation. The result of the BOM is paging information and logical SDOs matching the expression. This information is passed back by the fetch command which the GetNoun command will wrap in the ShowNoun response.
The following describes the detailed flow of the Get processing pattern as demonstrated in the preceding diagram:
- The get noun controller command executes and parses the get verb into a search expression.
- An access control check is performed to ensure the current user is allowed to use the access profile specified.
- The fetch command runs the search expression.
- The fetch command delegates to the business object mediator to run the search expression and returns a list of nouns matching the expression.
- There is an optional step of access control filtering of the data. The list of nouns returned by the fetch command is filtered to ensure the current user only views those nouns that they are allowed to see. To override this, we can override the filterNouns() method with an empty implementation.
Note: The Get controller can override this default behavior if it is not required, for example, for performance reasons. The disadvantage of doing so is that access control filtering will not be performed, but the advantage is that the service will perform better. If the Fetch noun task that obtains the data already includes this type of filter, then the filterNouns() read filtering is not required.
- The InsertMoreData command runs to retrieve additional data (which could be from alternate data sources) pertaining to the noun.
- The InsertMoreData command delegates to the business object mediator to execute the search expression and returns a list of nouns matching the expression.
Note: There can be one or more InsertMoreData commands defined per access profile.
- The nouns and the show verb is packaged in the ShowNoun response and returned.