In this chapter we cover step override and converters.

Step Override

When using common steps, we can override any step at task level.

In Example-8, defs/examples/jsoup/ex-8/job.xml, we override DataConverter step of commonSteps in bs task. The relevant snippet is shown below

<steps name="commonSteps">
    ...
    <step name="converter"
        class="org.codetab.gotz.step.convert.DataConverter">
        <nextStep>appender</nextStep>
    </step>
    ....
</steps>

<tasks name="quote tasks" group="quote">
    <task name="snapshot task" dataDef="snapshot">
        <steps ref="commonSteps" />
    </task>
    ....
</tasks>

<tasks name="bs" group="bs">
    <task name="bs" dataDef="bs">
        <steps ref="commonSteps">
          <step name="converter"
             class="org.codetab.gotz.step.convert.DataConverter">
              <nextStep>appender</nextStep>
              .....
          </step>
        </steps>
    </task>
    ....

The task snapshot uses commonSteps as it is but the task bs uses all steps from commonSteps except step converter. For converter, it uses the step defined locally.

 
 

Converters

Now we can use converter in the locally defined step so that converters are applied only to bs task and not to snapshot task.

The following snippet from the example defines converter to convert date in axis col.

<tasks name="bs" group="bs">
  <task name="bs" dataDef="bs">
    <steps ref="commonSteps">
      <step name="converter"
         class="org.codetab.gotz.step.convert.DataConverter">
          <nextStep>appender</nextStep>

         <converter name="date"
              class="org.codetab.gotz.step.convert.converter.DateRoller">
              <axis>col</axis>
              <inPattern>MMM ''YY</inPattern>
              <outPattern>YYYY-MM-dd</outPattern>
              <roll>DAY_OF_MONTH=ceil</roll>
          </converter>
      </step>
    </steps>
  </task>
  ....

It uses org.codetab.gotz.step.convert.converter.DateRoller which, based on inPattern and outPattern, changes the date pattern and also roll any date field to ceiling and floor. For example, if col axis date text is Dec ‘16, the DateRoller first changes the date to format YYYY-MM-dd and date becomes 2016-12-01, but as financial dates are normally month end we need to roll the date field DAY_OF_MONTH to ceiling to get month end date. Refer SimpleDateFormat for in and out patterns and Calendar for date fields.

 
 

To change the format we can use org.codetab.gotz.step.convert.converter.DateFormater but, to change format and adjust date we require DateRoller.