com.ibm.commerce.foundation.dataload.config

Interface ColumnHandler

  • All Known Implementing Classes:
    AbstractColumnHandler


    public interface ColumnHandler
    This class defines the interface for the custom extension to handle the column value in the TableObjectBuilder configuration. It will be used in the TableObjectMediator.

    The main purpose of the ColumnHandler is to resolve the column value based on the input values which cannot be simply mapped to the column value through the configuration. For example, to populate the password column in the database, your input is a clear text password, but the column in the database expects an encrypted value, you need to write a column handler to encrypt the clear password and return an encrypted password from the method resolveColumnValue().

    The TableObjectMediator will only create one instance of the ColumnHandler implementation class if the same implementation class is specified in more than one places in the TableObjectBuilder configuration. So the resolveColumnValue() method resolving value should only depend on the input parameters, not the position you defined in the configuration file.

    When defining the column 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 resolveColumnValue method as a parameter map.

    All implementation classes should extend from the AbstractColumnHandler class.

    See Also:
    AbstractColumnHandler
    • Field Summary

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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      void close()
      Close the class to release any resources it used, such as jdbc prepared statements.
      void init()
      Initializes the instance, such as creating some prepared statements to access the database.
      java.lang.String resolveColumnValue(java.util.Map<java.lang.String,java.lang.String> parameterMap, ExtendedTableDataObject extenededTableDataObject)
      Resolve the column value based on the input parameters passed in.
    • 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.
      • resolveColumnValue

        java.lang.String resolveColumnValue(java.util.Map<java.lang.String,java.lang.String> parameterMap,
                                            ExtendedTableDataObject extenededTableDataObject)
                                     throws DataLoadException
        Resolve the column value based on the input parameters passed in.

        The column handler will be called during each CSV line is processed.

        For example, if you define the following parameters in the ColumnHandler configuration:

         
                   <_config:Parameter name="LOGONID" value="logonId" />
         
        the parameter map will contain the map from LOGONID to the value of logonId. Most implementation classes will resolve the column value only depending on the parameter map. The extenededTableDataObject is provided in case you need to use some values from the extenededTableDataObject.
        Parameters:
        parameterMap - a parameter map which are name-value pairs defined in the configuration.
        extenededTableDataObject - the current table data object which contains the table configuration and some column values which have been resolved so far. You can also modify the object to update some column values.
        Returns:
        resolved new column value
        Throws:
        DataLoadException - if there are some errors to resolve the value.
      • 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.