Create custom data readers

Create a custom data reader to load data from a source that is not in a CSV file format, which is the default data source format of the Data Load utility. It is not necessary to change the format of your existing data to work with the Data Load utility.

Support for loading input files in a specific XML format with the Data Load utility is provided by default. For more information about the supported format for Data Load utility input files, see File format for Data Load input files. If your XML files use a different format that the format that is supported by default, create a custom XML data reader that supports the XML format of your files.

If we are using using this custom data reader with only the Data Load utility, you do not have to include custom class in the wc.ear directory when we deploy our custom data reader. If we are using this class with Management Center catalog upload feature, the class must be included in the wc.ear directory.


Before beginning

Ensure that you understand the following information:

Refer to the Creating a custom data reader tutorial for an example of how to create a custom data reader.


Procedure

  1. Open WebSphere Commerce Developer.

  2. Switch to the Java EE perspective.

  3. In the Enterprise Explorer view, double-click WebSphereCommerceServerExtensionsLogic to open this project.

    Note: We can create our custom data reader class in our own project, or in the WebSphereCommerceServerExtensionsLogic project.

  4. Create our custom data reader class by extending the abstract class AbstractDataReader. This AbstractDataReader abstract class is the default implementation of the DataReader interface.

  5. In our custom data reader class, implement the next() abstract method.

  6. Optional: Override the init(), close(), and getSourcePosition() methods to achieve the functionality that you need to read your existing data.

  7. Open the sample business object configuration file in the WCDE_installdir\samples\DataLoad directory.

  8. Change the default value of the className attribute inside the <_config:DataReader> element with the class name of our customized data reader.

  9. Update the default implementation of the business object configuration file to work with our customized data reader.

  10. Save and close the file.

  11. Repeat steps 5 and 6 for each of your business object configuration files.