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, you can use this topic to
help you create a custom XML data reader that supports the XML format
of your files.
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
- Open
WebSphere Commerce Developer.
- Switch to the Java EE perspective.
- 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.
- Create your custom data reader class by extending the abstract
class AbstractDataReader. This AbstractDataReader abstract
class is the default implementation of the DataReader interface.
- In your custom data reader class, implement the next() abstract
method.
- Optional: Override the init(), close(), and
getSourcePosition() methods to achieve the required functionality
to read your existing data.
- Open the sample business object configuration file in the WCDE_installdir\samples\DataLoad directory.
- Change the default value of the className attribute
inside the <_config:DataReader> element with
the class name of your customized data reader.
- Update the default implementation of the business object
configuration file to work with your customized data reader.
- Save and close the file.
- Repeat steps 5 and 6 for each of your business object configuration
files.
What to do next
Deploy your customized code. 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.
If you are using this class with Management Center catalog upload
feature, the class must be included in the wc.ear directory.