<beans:property name="resource" ref="customerTransactionFile"/>
<beans:property name="lineMapper" ref="customerTransactionLineMapper"/>
In Listing 10-12, you begin the configuration with the input file configuration. It's a
FileSystemResource like all your flat files have been; you specify the path to the file you process. From
there, you configure the customer and transaction LineTokenizers. These are simple
DelimitedLineTokenizers provided by the framework and configured to parse the comma-separated
record format you defined earlier. Next are the customer and transaction FieldSetMappers. These are
the two you wrote. Because they have no dependencies, they consist only of the bean definitions. The
next (and largest) piece of the configuration is RegularExpressionLineMapper . It has two dependencies: a
map of regular expressions to LineTokenizers and a map of the same regular expressions to
FieldSetMappers. Each map contains a single entry for each record type. The ItemReader follows in the
XML. In this case, you use a regular FlatFileItemReader for the implementation, passing it a reference to
your input file and a reference to your LineMapper ( RegularExpressionLineMapper ).
That's all you need to read the input required for the customerTransaction.csv file. But reading is
only half the process. The goal of this step is to get the data into your database. To do that, you need to
update each item with some ids for referential integrity to work. You look at the ItemProcessor
responsible for these updates in the next section.
Looking Ip Ids
Although the goal of this first step is to read the data from the customerTransaction.csv file and write it
to the database, the customer and transaction data needs some processing before you can do the write.
Per the requirements in Chapter 3, you need to insert customers if they don't exist currently in the
database and update them if they do. In this section, you write an ItemProcessor to update the customer
item if it exists in the database.
The items you get from customerTransactionReader can be either Customer objects or Transaction
objects. Because of this, the ItemProcessor needs to determine which type it is, update the ticker id and
the account id if it's a transaction, or look up the customer by social security number to get the database
id to update the Customer object before passing it along. Listing 10-13 has the code for
Listing 10-13. CustomerLookupItemProcessor