Tutorials > Management Center > Add new fields in the Catalogs tool

< Previous | Next >


Part 1: Adding language insensitive properties in the Catalogs tool

In this step, you customize the Catalogs tool to support warranty information to the CatalogEntry noun. Follow the same procedure for any language insensitive properties of a noun.

In this part, you complete the following tasks:


Procedure

  1. Update the wc-query-MyCompanyCatalogEntry-get.tpl file to add new data to the CatalogEntry noun.

    Before you update the query template file, it contains the following information:

    • A symbol definition section that defines the tables in the query template (CATENTRY, CATENTDESC, XWARRANTY, XCAREINSTRUCTION).

    • Definition of a new association SQL statement which seeks the new custom data.

    • Definition of a new access profile MyCompany_All which overrides the default CatalogEntry Details access profile IBM_Admin_Summary.

      IBM_Admin_ prefixes all services intended to be used by admin/Management Center based services calls. Access profiles which do not follow the new naming conventions continue to function correctly, as compatibility is maintained with earlier versions. It is recommended, however, that they are followed for existing access profiles, and when making changes to future access profiles. See Access profile naming conventions for more information.

    Tip: The data service layer tutorial demonstrated using a simple query template to add new data. In this tutorial, you update a Management Center query that displays catalog entries. Depending on how the query is defined by using associated queries, you might need to extend the access profile and add an associated query.

    1. In the Enterprise Explorer view, navigate to the WC\xml\config\com.ibm.commerce.catalog-ext folder.

    2. Open the wc-query-MyCompanyCatalogEntry-get.tpl file.

    3. Locate the following code:

      BEGIN_XPATH_TO_SQL_STATEMENT
      name=/CatalogEntry[CatalogEntryIdentifier[(UniqueID=)]]+MyCompany_All
      base_table=CATENTRY
      sql=
      SELECT
      CATENTRY.$COLS:CATENTRY$, CATENTDESC.$COLS:CATENTDESC$, XWARRANTY.$COLS:XWARRANTY$, XCAREINSTRUCTION.$COLS:XCAREINSTRUCTION$
      FROM
      CATENTRY
      LEFT OUTER JOIN XWARRANTY ON (CATENTRY.CATENTRY_ID = XWARRANTY.CATENTRY_ID)
      LEFT OUTER JOIN CATENTDESC ON (CATENTDESC.CATENTRY_ID = CATENTRY.CATENTRY_ID AND CATENTDESC.LANGUAGE_ID = $CTX:LANG_ID$)
        LEFT OUTER JOIN XCAREINSTRUCTION ON (CATENTRY.CATENTRY_ID = XCAREINSTRUCTION.CATENTRY_ID AND XCAREINSTRUCTION.LANGUAGE_ID = $CTX:LANG_ID$)
      WHERE
      CATENTRY.CATENTRY_ID IN (?UniqueID?) AND
      CATENTRY.MARKFORDELETE = 0
      END_XPATH_TO_SQL_STATEMENT
      

    4. Replace it with the following code:

      BEGIN_ASSOCIATION_SQL_STATEMENT
      name=MyCompanyWarrantygetCatalogEntryDetailsByParentCatalogGroupId
      base_table=CATENTRY
      additional_entity_objects=true
      sql=
      SELECT
      CATENTRY.$COLS:CATENTRY$, CATENTDESC.$COLS:CATENTDESC$, XWARRANTY.$COLS:XWARRANTY$, XCAREINSTRUCTION.$COLS:XCAREINSTRUCTION$
      FROM
      CATENTRY
      LEFT OUTER JOIN XWARRANTY ON (CATENTRY.CATENTRY_ID = XWARRANTY.CATENTRY_ID)
      LEFT OUTER JOIN CATENTDESC ON (CATENTDESC.CATENTRY_ID = CATENTRY.CATENTRY_ID AND CATENTDESC.LANGUAGE_ID in ($CONTROL:LANGUAGES$))
      LEFT OUTER JOIN XCAREINSTRUCTION ON (CATENTRY.CATENTRY_ID = XCAREINSTRUCTION.CATENTRY_ID AND XCAREINSTRUCTION.LANGUAGE_ID in ($CONTROL:LANGUAGES$))
      WHERE
      CATENTRY.CATENTRY_ID IN ($ENTITY_PKS$) AND
      CATENTRY.MARKFORDELETE = 0
      END_ASSOCIATION_SQL_STATEMENT
      

    5. Override the default access profile IBM_Admin_Summary. Add the following code at the bottom of the wc-query-MyCompanyCatalogEntry-get.tpl file:

      <!-- ========================================================================= -->
      <!-- =============================PROFILE DEFINITIONS========================= -->
      <!-- ========================================================================= -->
      
      BEGIN_PROFILE
      name=MyCompany_All
      extends = IBM_Admin_Details
      BEGIN_ENTITY
      associated_sql_statement=MyCompanyWarrantygetCatalogEntryDetailsByParentCatalogGroupId
      END_ENTITY
      END_PROFILE
      

      Where:

      name

      Name of the custom profile, for example MyCompany_All.

      extends

      Specify which default access profile you are going to extend, for example IBM_Admin_Details.

      associated_sql_statement

      New associated SQL statement for fetching the custom data for example, MyCompanyWarrantygetCatalogEntryDetailsByParentCatalogGroupId.

      To define a new access profile, see Access profiles. You do not need to copy all associated queries defined in the default CatalogEntry Details access profile, such as IBM_Admin_Details. By following the proceeding steps, both the existing catalog entry data and the new custom data are returned.

  2. Register the custom access profile on the client side.

    In this step, you configure the Management Center client to get the Warranty data.

    To register the custom access profile on the client side, create a custom configuration file (get-data-config.xml). The get-data-config.xml file configures how the Management Center retrieves the data from the server using the foundation tag library "<wcf:getData>". The extension version of this file (in the com.ibm.commerce.catalog-ext directory) overrides the original definition.

    The GetData tag configuration tag is configured by the WebSphere Commerce getData action. This action searches for configuration files named get-data-config.xml in the WEB-INF/config directory. The configuration files must adhere to the following rules:

    • The root element is get-data-config .

    • Each component has one configuration file that is used with the getData action.

    • Base component configuration files are located in the following directory: WEB-INF/config/base/component/get-data-config.xml. Where component is a directory that is unique to the component.

    • Client extensions are located... WEB-INF/config/component-ext. Client extensions are loaded after base component configurations.

    In get-data-config.xml file, specify the expression builder and the access profile information. The access profile is MyCompany_All. An expression builder is a helper class, or a template, declared in the WebSphere Commerce get-data-config.xml file. It is used by the getData tag in a JSP file to construct an XPath expression that retrieves data.

    1. Determine which expression builder to use.

      1. Determine the service URL name.

        To find the service URL name, you enable tracing in the Management Center.

        • Open the Administrative Console: http://localhost:9060/ibm/console/

        • Click Login without typing in the user id information

        • Expand Troubleshooting and select Logs and Trace.

        • Choose Server1 .

        • Select Change Log detail Levels

        • Enable trace, com.ibm.commerce.lobtools.*=all, in either the Configuration or Runtime tab:

          • Configuration tab

            The log messages display after restarting the server. When the server restarts, BOD message display without re-enabling trace in the Administrative Console.

          • Runtime tab

            The log message display without restarting the server. After restarting the server, trace must be re-enabled, otherwise the log message is not displayed.

          The preceding line must be terminated with a colon.

        • Save the change.

        • Launch the Management Center with parameter logger.display=true to enable the client logger. For more information about logging in Management Center see Open the Management Center.

        • Click Management Center > Logging and Tracing.

        • In the Logging and Tracing dialog, set the following options:

          • In the Default Log Level field select CONFIG.

          • Click Enable as shown below.

          Trace is enabled.

        • Log on to the Catalogs tool in Management Center, navigate to a product display page.

        • Click Send Now in Logging and Tracing panel.

        • Open WCDE_INSTALL\wasprofile\logs\server1\trace.log.

        • The trace appears as highlighted in the following example:

        The service URL is /cmc/GetCatalogGroupChildren-CatalogEntry.

      2. Determine the controller JSP file. In the Enterprise Explorer view, navigate to LOBTools > WebContent > WEB-INF and open the following file:

        • struts-ibm-tools.xml

        • struts-ibm-catalog.xml

        Search for the text "GetCatalogGroupChildren-CatalogEntry". The search finds the following line:

        <action path="/GetCatalogGroupChildren-CatalogEntry" forward="/jsp/commerce/catalog/restricted/GetChildCatalogEntryForCatalogGroup.jsp" />
        

        The controller JSP file is GetChildCatalogEntryForCatalogGroup.jsp.

      3. Determine the expression builder name. Open the GetChildCatalogEntryForCatalogGroup.jsp file. Note the value of the expressionBuilder, getCatalogEntryDetailsByParentCatalogGroupId.

        <wcf:getData type="com.ibm.commerce.catalog.facade.datatypes.CatalogEntryType[]"
        var="catalogEntryChildren"
        expressionBuilder="getCatalogEntryDetailsByParentCatalogGroupId"
        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="langId" data="${param.languageId}"/>
        <wcf:param name="catGroupId" value="${param.parentId}"/>
        </wcf:getData>
        

      The name of expression builder that we will declare in the custom get-data-config.xml file is getCatalogEntryDetailsByParentCatalogGroupId.

    2. Locate the IBM-provided expression builder, to override it.

      1. In the Enterprise Explorer view, navigate to LOBTools > WebContent > WEB-INF\config\com.ibm.commerce.catalog > get-data-config.xml.

      2. Open the get-data-config.xml file.

      3. Search for the expression builder name: getCatalogEntryDetailsByParentCatalogGroupId.

        <expression-builder>
        <name>getCatalogEntryDetailsByParentCatalogGroupId</name>
        <data-type-name>CatalogEntry</data-type-name>
        <expression-template>{_wcf.ap=$accessProfile$}/CatalogEntry[ParentCatalogGroupIdentifier[(UniqueID='$catGroupId$')]]</expression-template>
        <param>
        <name>accessProfile</name>
        <value>IBM_Admin_Summary</value>
        </param>
        </expression-builder>
        

      The default access profile is "IBM_Admin_Summary". You will override the expression builder by changing the value of the access profile.

    3. Create a custom, get-data-config.xml, configuration file.

      Warranty information is added to the CatalogEntry noun UserData element.

      To fetch extra Warranty information from catalogEntry, create a custom configuration file that overrides the base component configuration file.

      1. In the Enterprise Explorer view, navigate to LOBTools > WebContent > WEB-INF > config.

      2. Right-click config then click New > Folder.

      3. In the Folder name field, enter com.ibm.commerce.catalog-ext.

      4. Click Finish. The folder com.ibm.commerce.catalog-ext is created under the config directory.

      5. Right-click com.ibm.commerce.catalog-ext then click New > File.

      6. In the File name field, enter get-data-config.xml.

      7. Click Finish. The get-data-config.xml file opens.

      8. Copy the following code to the extended get-data-config.xml:

        <?xml version="1.0" encoding="UTF-8"?>
        <wcf:get-data-config
        xmlns:wcf="http://www.ibm.com/xmlns/prod/commerce/foundation"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation ../../xsd/get-data-config.xsd ">
        <expression-builder>
        <name>getCatalogEntryDetailsByParentCatalogGroupId</name>
        <data-type-name>CatalogEntry</data-type-name>
        <param>
        <name>accessProfile</name>
        <value>MyCompany_All</value>
        </param>
        </expression-builder>
        </wcf:get-data-config>
        

        In the code that you copy, the expression template is not included; this expression builder will use the access profile that you defined and the expression template from the IBM-provided definition. This is because the name, getCatalogEntryDetailsByParentCatalogGroupId is the same, that is you have extended the expression builder.


Lesson checkpoint

So far, you have registered the custom access profile on the client side, so that client side can communicate with the server side. In the next step we will start on customizing the client side GUI.

< Previous | Next >


+

Search Tips   |   Advanced Search