-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
footballJob.xml
111 lines (101 loc) · 4.66 KB
/
footballJob.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/batch https://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<job id="footballJob" xmlns="http://www.springframework.org/schema/batch">
<step id="playerload" next="gameLoad">
<tasklet>
<chunk reader="playerFileItemReader" writer="playerWriter"
commit-interval="#{jobParameters['commit.interval']}"/>
</tasklet>
</step>
<step id="gameLoad" next="playerSummarization">
<tasklet>
<chunk reader="gameFileItemReader" writer="gameWriter"
commit-interval="${job.commit.interval}" />
</tasklet>
</step>
<step id="playerSummarization" parent="summarizationStep" />
</job>
<step id="summarizationStep" xmlns="http://www.springframework.org/schema/batch">
<tasklet>
<chunk reader="playerSummarizationSource" writer="summaryWriter"
commit-interval="${job.commit.interval}" />
</tasklet>
</step>
<bean id="playerWriter" class="org.springframework.batch.core.test.football.internal.PlayerItemWriter">
<property name="playerDao">
<bean class="org.springframework.batch.core.test.football.internal.JdbcPlayerDao">
<property name="dataSource" ref="dataSource" />
</bean>
</property>
</bean>
<bean id="gameWriter" class="org.springframework.batch.core.test.football.internal.JdbcGameDao">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="summaryWriter" class="org.springframework.batch.core.test.football.internal.JdbcPlayerSummaryDao">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="playerFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="classpath:data/football/${player.file.name}" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="ID,lastName,firstName,position,birthYear,debutYear" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.core.test.football.internal.PlayerFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<bean id="gameFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="classpath:data/football/${games.file.name}" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="id,year,team,week,opponent,completes,attempts,passingYards,passingTd,interceptions,rushes,rushYards,receptions,receptionYards,totalTd" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.core.test.football.internal.GameFieldSetMapper" />
</property>
</bean>
</property>
</bean>
<bean id="playerSummarizationSource" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="verifyCursorPosition" value="${batch.verify.cursor.position}" />
<property name="rowMapper">
<bean class="org.springframework.batch.core.test.football.internal.PlayerSummaryMapper" />
</property>
<property name="sql">
<value>
SELECT GAMES.player_id, GAMES.year_no, SUM(COMPLETES),
SUM(ATTEMPTS), SUM(PASSING_YARDS), SUM(PASSING_TD),
SUM(INTERCEPTIONS), SUM(RUSHES), SUM(RUSH_YARDS),
SUM(RECEPTIONS), SUM(RECEPTIONS_YARDS), SUM(TOTAL_TD)
from GAMES, PLAYERS where PLAYERS.player_id =
GAMES.player_id group by GAMES.player_id, GAMES.year_no
</value>
</property>
</bean>
<bean id="footballProperties" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="properties">
<value>
games.file.name=games-small.csv
player.file.name=player-small.csv
job.commit.interval=2
</value>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="1" />
</bean>
</beans>