Java Reference
In-Depth Information
<job id="statementJob" incrementer="idIncrementer">
<step id="step1" parent="importCustomerAndTransactionData" next="step2"/>
<step id="step2" parent="retrieveStockPrices" next="step3"/>
<step id="step3" parent="importStockPrices" next="step4"/>
<step id="step4" parent="calculateTiers"/>
The configuration in Listing 10-30 begins with the definition of the
accountTransactionQtyItemReader —the JdbcCursorItemReader with its three dependencies: a
datasource, the select statement that gets you each account number and the number of transactions
the account has, and a reference to the RowMapper implementation you developed. The configuration
for this RowMapper is next, followed by the step that is configured to use the ItemReader.
Now that you can read in a customer's transaction history, you can calculate the pricing tier they fall
into. In the next section, you look at the ItemProcessor you use to do that calculation.
Calculating the Pricing Tier
In the previous section, you defined an AccountTransactionQuantity object that you use as the item into
which your reader reads the data. It contains two fields: an account number and a transaction count (the
number of transactions the customer performed during the month). To calculate the tiers, you add a
PricingTier reference to the AccountTransactionQuantity object. Listing 10-31 shows the updated
AccountTransactionQuantity object and the related PricingTier enum .
Listing 10-31. AccountTransactionQuantity and PricingTier
package com.apress.springbatch.statement.domain;
public class AccountTransactionQuantity {
private String accountNumber;
private long transactionCount;
private PricingTier tier;
// Accessors go here
public String toString() {
return accountNumber + " has " + transactionCount +
" transactions this month wich falls into tier " + tier;
package com.apress.springbatch.statement.domain;
public enum PricingTier {
UNDEFINED(0), I(1), II(2), III(3), IV(4);
private int value;
Search WWH ::

Custom Search