Develop > Business logic layer > Work with the data service layer > Extend the WebSphere Commerce schema using the data service layer


Extend the provided get-data-config.xml file

You should extend the get-data-config.xml file when the configuration file has been provided for you. By extending the configuration, you can override the properties of the expression builder.

Complete this task when extending a service module, where the configuration file has been provided for you. If you are creating a new service module and the configuration file has not been provided for you, , however, create a new configuration file instead.


Procedure

  1. Create the get-data-config.xml file for the project.

    • Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.

    • In the Enterprise Explorer view, expand YourProject > WebContent > WEB_INF > config.

      Where YourProject is the project running the code using the getData tag.

    • Right-click config and select New > Folder.

    • In the Folder name field, enter com.mycompany.commerce.project-ext and click Finish.

      When creating any extensions folder, the folder name immediately ends with -ext. This ensures the original get-data-config.xml file located in the folder immediately preceding it remains unchanged. Instead, by extending the configuration, you can override the properties of the expression builder.

    • If the com.mycompany.commerce.project-ext folder is not visible, right-click on the config directory in the Enterprise Explorer view and click Refresh.

    • Right-click the com.mycompany.commerce.project-ext folder and select New > File .

    • In the File name field, enter get-data-config.xml and click Finish. The newly created get-data-config.xml extension file automatically opens.

  2. Determine which expression builders to extend from the base get-data-config.xml file and copy them into the extension file:

    1. Navigate to the folder immediately preceding the extension folder and double click the original provided get-data-config.xml file to open it in the default editor.

    2. Locate the expression builder definitions to extend and copy the section between each <expression-builder> and </expression-builder> tags.

    3. Paste the content copied from the base get-data-config.xml file into the extended get-data-config.xml file, before the </wcf:get-data-config> line at the end of this file.

  3. Update the new expression builder in the extended get-data-config.xml file.

    Each expression builder has the following properties:

    • The name node uniquely identifies the expression builder, and is used by getData tags in the project JSP files when referring to an expression builder.

    • The data-type-name node contains the noun type returned by this expression builder.

    • The expression template node refers to an XPath query defined in the project query template file, used to retrieve specific information from the database. Parameters such as $projectID$ can be passed to the expression builder by a getData tag.

    • Each param node contains a pair of name and value child nodes that define a parameter passed to the query template file. Each expression builder is associated with a specific Access Profile. This Access Profile, together with the defined XPath query, uniquely identifies a query in the query template file.

    You should only change the items to override in each expression builder.

    Each expression builder should resemble the following sample structure, replacing the empty nodes with the own project-related expression builders. Depending on which items to override, every node below may not reflect your changes:

    <!-- Project related expression builder extension 1. Note: every node may not apply to the specific scenario. -->    
    <expression-builder>         <name>
    </name>         <data-type-name>
    </data-type-name>         <expression-template>
    </expression-template>         <param>             <name>
    </name>             <value>
    </value>         </param>     </expression-builder> 
    <!-- Project related expression builder extension 2. Note: every node may not apply to the specific scenario. -->
    <expression-builder>         <name>
    </name>         <data-type-name>
    </data-type-name>         <expression-template>
    </expression-template>         <param>             <name>
    </name>             <value>
    </value>         </param>     </expression-builder> 
        <!-- Project related expression builder extension 3. Note: every node may not apply to the specific scenario. -->
    <expression-builder>         <name>
    </name>         <data-type-name>
    </data-type-name>         <expression-template>
    </expression-template>         <param>             <name>
    </name>             <value>
    </value>         </param>     </expression-builder>
    </wcf:get-data-config>
    

    Although there are three expression builders in the sample expression builder structure, the own project-related expression builders can contain as many expression builders as needed.

  4. Deploy the changes using the WebSphere Administrative Console or the wsadmin tool:

    Deploy J2EE assets for a single file

    Deploys a single file asset into the J2EE application. Use this option to deploy the changes if the new get-data-config.xml file is the only file being changed.

    Deploy J2EE assets for a partial application

    Deploys several files into the J2EE application at the same time. Use this option to deploy the changes if changes have been made to more files than just the new get-data-config.xml file. For example: logic jars, JSP files, or other configuration XML files.


Results

After completing these steps, you have successfully extended a service module when the configuration file has been provided for you.


Related tasks

Work with WebSphere Commerce service modules

Work with the data service layer

Create a new get-data-config.xml file


+

Search Tips   |   Advanced Search