Creating 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.

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

Before you begin

Ensure that you understand the following information:
  • The format of the source data that the data reader uses as input. For example, if your source data is in XML format, it is important to understand the DTD or XSD to create a custom data reader that can parse the XML source document.
  • The API for the com.ibm.commerce.foundation.dataload.datareader.AbstractDataReader abstract class.
  • The API for the com.ibm.commerce.foundation.dataload.datareader.DataReader interface.

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: You can create your custom data reader class in your own project, or in the WebSphereCommerceServerExtensionsLogic project.
  4. Create your custom data reader class by extending the abstract class AbstractDataReader. This AbstractDataReader abstract class is the default implementation of the DataReader interface.
  5. In your custom data reader class, implement the next() abstract method.
  6. Optional: Override the init(), close(), and getSourcePosition() methods to achieve the functionality thqt 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 your customized data reader.
  9. Update the default implementation of the business object configuration file to work with your customized data reader.
  10. Save and close the file.
  11. Repeat steps 5 and 6 for each of your business object configuration files.