com.ibm.commerce.foundation.dataload.config

Interface TableHandler

  • All Known Implementing Classes:
    AbstractTableHandler


    public interface TableHandler
    This class defines the interface for the custom extension to handle the table data object in the TableObjectBuilder configuration. It will be used in the TableObjectMediator.

    The main purpose of TableHandler is to create some extra rows in the table based on the current table data object. All logic should be implemented in the method createExtraTableDataObjects(). For example, if you use the TableObjectMediator to populate the MBRREL table for a user. To create one row in this table for the user to its parent relation is not enough. It needs to populate all relations from the user to all ancestors. So in the method createExtraTableDataObjects(), you need to create all extra relations and return them as a list of TableDataObject.

    The TableObjectMediator will only create one instance of the implementation class if the same implementation class is specified in more than one places in the TableObjectBuilder configuration. So the createExtraTableDataObjects() method creating extra table data objects should only depend on the input parameters, not the position you defined in the configuration file.

    When defining the table handler in the configuration, it can associate with a list of parameters which are name-value pairs. These name value pairs will be passed to the createExtraTableDataObject method as a parameter map.

    All implementation classes should extend from the AbstractTableHandler class.

    See Also:
    AbstractTableHandler
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright notice field.
    • Field Detail

      • COPYRIGHT

        static final java.lang.String COPYRIGHT
        IBM Copyright notice field.
        See Also:
        Constant Field Values
    • Method Detail

      • init

        void init()
           throws DataLoadException
        Initializes the instance, such as creating some prepared statements to access the database. This method will be called only once before any lines in the CSV file are processed.
        Throws:
        DataLoadException - if there are some errors.
      • preProcess

        void preProcess(ExtendedTableDataObject extendedTableDataObject)
                 throws DataLoadException
        It is called in the TableObjectMediaotr for every line in the CSV file. It is called before any column values are handled. You may pre-populate some column values in the extendedTableDataObject.
        Parameters:
        extendedTableDataObject - an extended table data object.
        Throws:
        DataLoadException - if there are some errors.
      • createExtraTableDataObjects

        java.util.List<TableDataObject> createExtraTableDataObjects(java.util.Map<java.lang.String,java.lang.String> parameterMap,
                                                                    ExtendedTableDataObject extendedTableDataObject)
                                                             throws DataLoadException
        Execute the custom logic to handle the table data object. It can create some extra table data objects based on the current extendedTableDataObject and the other input parameters. This method is called after all column values are resolved for this table configuration and before the data are saved in the database. If you don't create any extra table data object, you can return null or an empty list. You can just modify the extendedTableDataObject.
        Parameters:
        parameterMap - a parameter map which name-value pairs defined in the configuration.
        extendedTableDataObject - an extended table data object. This object contains all data which will be loaded into the database. You can base on the data in this object and create a few more table data objects to be loaded into database. You may also modify the data in this object.
        Returns:
        some additional table data objects it generates. It may return a null or an empty list.
        Throws:
        DataLoadException - if there are some errors to execute the custom logic.
      • setDeleteFlag

        void setDeleteFlag(boolean deleteFlag)
        Sets the delete flag. It is called every time before the method createExtraTableDataObjects() is called. It is set to true if the data load mode is delete or the delete flag is passed in from the input data.
        Parameters:
        deleteFlag - a boolean flag.
      • close

        void close()
        Close the class to release any resources it used, such as JDBC prepared statements. This method will be called only once after all lines in the CSV file are processed.