com.ibm.commerce.foundation.dataload.config

Class PatternValueHandler

  • All Implemented Interfaces:
    ValueHandler


    public class PatternValueHandler
    extends AbstractValueHandler
    The PatternValueHandler will allow you to specify a pattern and the token values to be replaced in the pattern.
    The pattern parameter is called "pattern". If this parameter is not specified, the value of the corresponding database column will be used as pattern. All rest of the parameters will be used as token/value for replacing in the pattern.
    For example, in wc-extract-catentdesc.xml, define the following section:
                <_config:Query>
                  <_config:SQL>
                        <![CDATA[
                                    SELECT CATENTDESC.CATENTRY_ID, LANGUAGE_ID, NAME, PARTNUMBER, THUMBNAIL, FULLIMAGE, PUBLISHED
                                    FROM CATENTDESC, CATENTRY WHERE CATENTRY.CATENTRY_ID = CATENTDESC.CATENTRY_ID AND CATENTRY.CATENTRY_ID=? AND LANGUAGE_ID=?
                        ]]>
                  </_config:SQL>
                  <_config:Param name="CATENTRY_ID" />
                  <_config:Param name="LANGUAGE_ID" />
                  
                  <_config:ColumnMapping name="THUMBNAIL" value="THUMBNAIL">
                             <_config:ValueHandler className="com.ibm.commerce.foundation.dataload.config.PatternValueHandler" >
                                    <_config:Parameter name="pattern" value="thumbnail/partNumber.jpg" valueFrom="Fixed" />
                                    <_config:Parameter name="partNumber" value="PARTNUMBER"/>
                             </_config:ValueHandler>
                  </_config:ColumnMapping>
                </_config:Query>
     
    The pattern is defined as "thumbnail/partNumber.jpg". There is another parameter called "partNumber". This parameter will be treated as token parameter. This value handler will replace the "partNumber" in the pattern "thumbnail/partNumber.jpg" with the value of the actual part number. In the end, the thumbnail column value in the output CSV will be like "thumbnail/AuroraWMDRS-1.jpg". Note that more than one token parameters can be defined.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.String resolveValue(java.lang.String inputValue, java.util.Map<java.lang.String,java.lang.String> parameterMap, java.lang.Object dataObject)
      Resolve the value based on the input parameters passed in.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PatternValueHandler

        public PatternValueHandler()
    • Method Detail

      • resolveValue

        public java.lang.String resolveValue(java.lang.String inputValue,
                                             java.util.Map<java.lang.String,java.lang.String> parameterMap,
                                             java.lang.Object dataObject)
                                      throws DataLoadException
        Resolve the value based on the input parameters passed in. The value handler will be called during each CSV line is processed.
        Parameters:
        inputValue - an input value
        parameterMap - a parameter map which contains the parameter name-value pairs.
        dataObject - an optional data object to help to resolve the value.
        Returns:
        resolved new value
        Throws:
        DataLoadException - if there are some errors to resolve the value.