Introduced in Feature Pack 3

Extending the data reader class to extract category-level SKUs

To extract category-level SKUs, you must extend the CatalogEntryReaderMediator class by creating a subclass that invokes the Get service created in the previous task. The subclass retrieves the details about the products and category-level SKUs.

The data extraction utility uses the CatalogEntryReaderMediator class to invoke the component services to extract the catalog entry records from the WebSphere Commerce database for inclusion in the EPCMF file.

Before you begin

Review the documentation for the class you are going to extend:

com.ibm.commerce.catalog.dataload.datareader.CatalogEntryReaderMediator

Procedure

  1. Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
  2. Create a package for your extended Java class files:
    1. Navigate to WebSphereCommerceServerExtensionsLogic > src.
    2. Right-click the src folder; then click New > Package.
    3. In the Name field, type:

      com.your_company_name.commerce.catalog.dataload.datareader

    4. Click Finish.
  3. In the new package, create a new class that extends from the com.ibm.commerce.catalog.dataload.datareader.CatalogEntryReaderMediator class.
    Name the class ExtCatalogEntryReaderMediator.
    The new class must:
    • Override the getDataObject(String beginIndex, String pageSize, String storeId) method in the CatalogEntryReaderMediator class.
    • Invoke the newly created Get service to retrieve the necessary information.

    Here is an example of this extended class:

    public class ExtCatalogEntryReaderMediator extends CatalogEntryReaderMediator {
         /*
         * Logger used for logging.
         */
         private   static   final  Logger LOGGER  = LoggingHelper. getLogger (ExtCatalogEntryReaderMediator. class );
        
         /*
         * Class name used for trace and logging.
         */
         private   static   final  String CLASSNAME  = ExtCatalogEntryReaderMediator.  class .getName();
         
         /*
         * The catalog entry xpath  expression
         */
         private   static   final  String CATALOG_ENTRY_XPATH_EXPRESSION  = "/CatalogEntry[CatalogEntryIdentifier[ExternalIdentifier[StoreIdentifier[(UniqueID={0})]]] and CategoryLevelSKU]" ;
         
         protected  Object getDataObject(String beginIndex, String pageSize, String storeId) throws  AbstractBusinessObjectDocumentException, DataLoadException {
              final  String METHODNAME = "getDataObject" ;
              if (LoggingHelper. isEntryExitTraceEnabled ( LOGGER )) {
                   LOGGER .entering( CLASSNAME , METHODNAME, new  Object[]{beginIndex, pageSize, storeId}); 
              }
              
              GetType getVerb = Oagis9Factory. eINSTANCE .createGetType();
              String accessProfile = getAccessProfile();
              
              // Instantiate SelectionCriteriaHelper object
              SelectionCriteriaHelper selectionCriteriaHelper = new  SelectionCriteriaHelper(MessageFormat. format ( CATALOG_ENTRY_XPATH_EXPRESSION , new  Object[]{storeId.trim()})); 
              
              selectionCriteriaHelper.addAccessProfile(accessProfile); 
              selectionCriteriaHelper.setDataLanguageIds(getLanguageId());
              
              if (isCloudscape()){
                   getVerb.setRecordSetStartNumber( new  BigInteger(beginIndex));
                   getVerb.setMaxItems( new  BigInteger(pageSize));
              }
              else {
                   // Set the control parameter, beginIndex
                   selectionCriteriaHelper.addNameValuePair( new  RelationalExpression(DataExtractConstants. DE_CONTROL_PARAMETER_BEGIN_INDEX , beginIndex));
                   
                   // Set the control parameter, maxItems
                   selectionCriteriaHelper.addNameValuePair( new  RelationalExpression(DataExtractConstants. DE_CONTROL_PARAMETER_MAX_ITEMS , pageSize));
              }
              
              // Set the Currency as a control parameter
              selectionCriteriaHelper.addNameValuePair( new  RelationalExpression(DataExtractConstants. DE_CONTROL_PARAMETER_CURRENCY , getCurrency()));
              
              // Set the control parameters from the control parameters map in the request
              Map controlParametersMap = getControlParametrs();
              Iterator it = controlParametersMap.entrySet().iterator();
              while  (it.hasNext()) {
                 Map.Entry pairs = (Map.Entry)it.next();
                 selectionCriteriaHelper.addNameValuePair( new  RelationalExpression((String)pairs.getKey(), (String)pairs.getValue()));
              }
              
              ExpressionType queryExpression = selectionCriteriaHelper.getSelectionCriteriaExpression(); 
              queryExpression.setExpressionLanguage(DataExtractConstants. DE_EXPRESSION_LANGUAGE_XPATH );
              getVerb.getExpression().add(queryExpression);
              
              CatalogEntryFacadeClient catEntryClient = new  CatalogEntryFacadeClient(getBusinessContext(), getCallBackHandler());
              ShowCatalogEntryDataAreaType result = catEntryClient.getCatalogEntry(getVerb);
              
              if (LoggingHelper. isEntryExitTraceEnabled ( LOGGER )) {
                   LOGGER .exiting( CLASSNAME , METHODNAME, result);
              }
              return  result;
         }
    } 
  4. Save and close the class file.