BATCH-248:Removed Brand from sample job.

This commit is contained in:
lucasward
2007-12-05 00:43:16 +00:00
parent 9eef9f926d
commit da7d198866
28 changed files with 197 additions and 200 deletions

View File

@@ -11,5 +11,5 @@
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;core&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;execution&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;infrastructure&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.springframework.batch.execution.bootstrap.support.BatchCommandLineLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="samples"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djob.configuration.path=jobs/nflJob.xml -Djob.name=nfljob"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Djob.configuration.path=jobs/footballJob.xml -Djob.name=footballjob"/>
</launchConfiguration>

View File

@@ -23,7 +23,7 @@
<config>src/main/resources/jobs/hibernateJob.xml</config>
<config>src/main/resources/jobs/ibatisJob.xml</config>
<config>src/main/resources/jobs/compositeProcessorSampleJob.xml</config>
<config>src/main/resources/jobs/nflJob.xml</config>
<config>src/main/resources/jobs/footballJob.xml</config>
<config>src/main/resources/jobs/simpleTaskletJob.xml</config>
<config>src/main/resources/beanRefContext.xml</config>
<config>src/main/resources/jobs/delegatingJob.xml</config>
@@ -143,13 +143,13 @@
</configs>
</configSet>
<configSet>
<name><![CDATA[nfl]]></name>
<name><![CDATA[football]]></name>
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
<incomplete>false</incomplete>
<configs>
<config>src/main/resources/data-source-context.xml</config>
<config>src/main/resources/simple-container-definition.xml</config>
<config>src/main/resources/jobs/nflJob.xml</config>
<config>src/main/resources/jobs/footballJob.xml</config>
</configs>
</configSet>
<configSet>

View File

@@ -187,10 +187,10 @@
</includes>
<excludes>
<exclude>**/Abstract*.java</exclude>
<exclude>**/NflJobFunctionalTests.java</exclude>
<exclude>**/FootballJobFunctionalTests.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>

View File

@@ -1,8 +0,0 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.NflPlayer;
public interface NflPlayerDao {
void savePlayer(NflPlayer nflPlayer);
}

View File

@@ -0,0 +1,8 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.Player;
public interface PlayerDao {
void savePlayer(Player player);
}

View File

@@ -1,21 +1,21 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.io.ItemWriter;
import org.springframework.batch.sample.domain.NflGame;
import org.springframework.batch.sample.domain.Game;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.util.Assert;
public class SqlNflGameDao extends JdbcDaoSupport implements ItemWriter {
public class SqlGameDao extends JdbcDaoSupport implements ItemWriter {
private static final String INSERT_GAME = "INSERT into GAMES(player_id,year,team,week,opponent,"
+ "completes,attempts,passing_yards,passing_td,interceptions,rushes,rush_yards,"
+ "receptions,receptions_yards,total_td) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
public void write(Object output) {
Assert.isTrue(output instanceof NflGame,
"Only NflGame objects can be written out" + "using this Dao");
Assert.isTrue(output instanceof Game,
"Only Game objects can be written out" + "using this Dao");
NflGame game = (NflGame) output;
Game game = (Game) output;
Object[] args = new Object[] { game.getId(),
new Integer(game.getYear()), game.getTeam(),

View File

@@ -1,30 +0,0 @@
/**
*
*/
package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.NflPlayer;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
/**
* @author Lucas Ward
*
*/
public class SqlNflPlayerDao extends JdbcDaoSupport implements NflPlayerDao {
public static final String INSERT_PLAYER = "INSERT into players(player_id, " +
"last_name, first_name, pos, year_of_birth, year_drafted)" +
" values (?,?,?,?,?,?)";
/* (non-Javadoc)
* @see com.nfl.NflPlayerDao#savePlayer(com.nfl.NflPlayer)
*/
public void savePlayer(NflPlayer nflPlayer) {
getJdbcTemplate().update(INSERT_PLAYER,
new Object[]{nflPlayer.getID(),nflPlayer.getLastName(),
nflPlayer.getFirstName(), nflPlayer.getPosition(),
new Integer(nflPlayer.getBirthYear()),
new Integer(nflPlayer.getDebutYear())});
}
}

View File

@@ -0,0 +1,27 @@
/**
*
*/
package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.Player;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
/**
* @author Lucas Ward
*
*/
public class SqlPlayerDao extends JdbcDaoSupport implements PlayerDao {
public static final String INSERT_PLAYER = "INSERT into players(player_id, " +
"last_name, first_name, pos, year_of_birth, year_drafted)" +
" values (?,?,?,?,?,?)";
public void savePlayer(Player player) {
getJdbcTemplate().update(INSERT_PLAYER,
new Object[]{player.getID(),player.getLastName(),
player.getFirstName(), player.getPosition(),
new Integer(player.getBirthYear()),
new Integer(player.getDebutYear())});
}
}

View File

@@ -1,11 +1,11 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.io.ItemWriter;
import org.springframework.batch.sample.domain.NflPlayerSummary;
import org.springframework.batch.sample.domain.PlayerSummary;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.util.Assert;
public class SqlNflPlayerSummaryDao extends JdbcDaoSupport implements ItemWriter {
public class SqlPlayerSummaryDao extends JdbcDaoSupport implements ItemWriter {
private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID,YEAR,COMPLETES,ATTEMPTS," +
"PASSING_YARDS,PASSING_TD,INTERCEPTIONS,RUSHES,RUSH_YARDS,RECEPTIONS,RECEPTIONS_YARDS," +
@@ -13,10 +13,10 @@ public class SqlNflPlayerSummaryDao extends JdbcDaoSupport implements ItemWriter
public void write(Object output) {
Assert.isInstanceOf(NflPlayerSummary.class, output, SqlNflPlayerSummaryDao.class.getName() + " only " +
"supports outputing " + NflPlayerSummary.class.getName() + " instances.");
Assert.isInstanceOf(PlayerSummary.class, output, SqlPlayerSummaryDao.class.getName() + " only " +
"supports outputing " + PlayerSummary.class.getName() + " instances.");
NflPlayerSummary summary = (NflPlayerSummary)output;
PlayerSummary summary = (PlayerSummary)output;
Object[] args = new Object[]{summary.getId(), Integer.valueOf(summary.getYear()),
Integer.valueOf(summary.getCompletes()), Integer.valueOf(summary.getAttempts()),

View File

@@ -2,7 +2,7 @@ package org.springframework.batch.sample.domain;
import org.apache.commons.lang.builder.EqualsBuilder;
public class NflGame {
public class Game {
private String id;
private int year;
@@ -203,7 +203,7 @@ public class NflGame {
public String toString() {
return "NFL Game: ID=" + id + " " + team + " vs. " + opponent +
return "Game: ID=" + id + " " + team + " vs. " + opponent +
" - " + year;
}

View File

@@ -1,6 +1,6 @@
package org.springframework.batch.sample.domain;
public class NflPlayer {
public class Player {
private String ID;
private String lastName;
@@ -11,7 +11,7 @@ public class NflPlayer {
public String toString() {
return "NFL-PLAYER:ID=" + ID + ",Last Name=" + lastName +
return "PLAYER:ID=" + ID + ",Last Name=" + lastName +
",First Name=" + firstName + ",Position=" + position +
",Birth Year=" + birthYear + ",DebutYear=" +
debutYear;

View File

@@ -3,13 +3,13 @@ package org.springframework.batch.sample.domain;
import org.apache.commons.lang.builder.EqualsBuilder;
/**
* Domain object representing the summary of a given Nfl Player's
* Domain object representing the summary of a given Player's
* year.
*
* @author Lucas Ward
*
*/
public class NflPlayerSummary {
public class PlayerSummary {
private String id;
private int year;
@@ -99,7 +99,7 @@ public class NflPlayerSummary {
public String toString() {
return "NFL Player Summary: ID=" + id + " Year=" + year;
return "Player Summary: ID=" + id + " Year=" + year;
}
public boolean equals(Object obj) {

View File

@@ -5,10 +5,10 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.exception.handler.ExceptionHandler;
public class NflExceptionHandler implements ExceptionHandler {
public class FootballExceptionHandler implements ExceptionHandler {
private static final Log logger = LogFactory
.getLog(NflExceptionHandler.class);
.getLog(FootballExceptionHandler.class);
public void handleException(RepeatContext context, Throwable throwable)
throws RuntimeException {

View File

@@ -1,18 +0,0 @@
package org.springframework.batch.sample.item.processor;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.sample.dao.NflPlayerDao;
import org.springframework.batch.sample.domain.NflPlayer;
public class NflPlayerItemProcessor implements ItemProcessor {
NflPlayerDao nflPlayerDao;
public void process(Object data) throws Exception {
nflPlayerDao.savePlayer((NflPlayer)data);
}
public void setNflPlayerDao(NflPlayerDao nflPlayerDao) {
this.nflPlayerDao = nflPlayerDao;
}
}

View File

@@ -0,0 +1,18 @@
package org.springframework.batch.sample.item.processor;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.sample.dao.PlayerDao;
import org.springframework.batch.sample.domain.Player;
public class PlayerItemProcessor implements ItemProcessor {
PlayerDao playerDao;
public void process(Object data) throws Exception {
playerDao.savePlayer((Player)data);
}
public void setPlayerDao(PlayerDao playerDao) {
this.playerDao = playerDao;
}
}

View File

@@ -0,0 +1,35 @@
package org.springframework.batch.sample.mapping;
import org.springframework.batch.io.file.FieldSet;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.sample.domain.Game;
public class GameMapper implements FieldSetMapper {
public Object mapLine(FieldSet fs) {
if(fs == null){
return null;
}
Game game = new Game();
game.setId(fs.readString("id"));
game.setYear(fs.readInt("year"));
game.setTeam(fs.readString("team"));
game.setWeek(fs.readInt("week"));
game.setOpponent(fs.readString("opponent"));
game.setCompletes(fs.readInt("completes"));
game.setAttempts(fs.readInt("attempts"));
game.setPassingYards(fs.readInt("passingYards"));
game.setPassingTd(fs.readInt("passingTd"));
game.setInterceptions(fs.readInt("interceptions"));
game.setRushes(fs.readInt("rushes"));
game.setRushYards(fs.readInt("rushYards"));
game.setReceptions(fs.readInt("receptions", 0));
game.setReceptionYards(fs.readInt("receptionYards"));
game.setTotalTd(fs.readInt("totalTd"));
return game;
}
}

View File

@@ -1,35 +0,0 @@
package org.springframework.batch.sample.mapping;
import org.springframework.batch.io.file.FieldSet;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.sample.domain.NflGame;
public class NflGameMapper implements FieldSetMapper {
public Object mapLine(FieldSet fs) {
if(fs == null){
return null;
}
NflGame nflGame = new NflGame();
nflGame.setId(fs.readString("id"));
nflGame.setYear(fs.readInt("year"));
nflGame.setTeam(fs.readString("team"));
nflGame.setWeek(fs.readInt("week"));
nflGame.setOpponent(fs.readString("opponent"));
nflGame.setCompletes(fs.readInt("completes"));
nflGame.setAttempts(fs.readInt("attempts"));
nflGame.setPassingYards(fs.readInt("passingYards"));
nflGame.setPassingTd(fs.readInt("passingTd"));
nflGame.setInterceptions(fs.readInt("interceptions"));
nflGame.setRushes(fs.readInt("rushes"));
nflGame.setRushYards(fs.readInt("rushYards"));
nflGame.setReceptions(fs.readInt("receptions", 0));
nflGame.setReceptionYards(fs.readInt("receptionYards"));
nflGame.setTotalTd(fs.readInt("totalTd"));
return nflGame;
}
}

View File

@@ -1,27 +0,0 @@
package org.springframework.batch.sample.mapping;
import org.springframework.batch.io.file.FieldSet;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.sample.domain.NflPlayer;
public class NflPlayerMapper implements FieldSetMapper {
public Object mapLine(FieldSet fs) {
if(fs == null){
return null;
}
NflPlayer nflPlayer = new NflPlayer();
nflPlayer.setID(fs.readString("ID"));
nflPlayer.setLastName(fs.readString("lastName"));
nflPlayer.setFirstName(fs.readString("firstName"));
nflPlayer.setPosition(fs.readString("position"));
nflPlayer.setDebutYear(fs.readInt("debutYear"));
nflPlayer.setBirthYear(fs.readInt("birthYear"));
return nflPlayer;
}
}

View File

@@ -0,0 +1,27 @@
package org.springframework.batch.sample.mapping;
import org.springframework.batch.io.file.FieldSet;
import org.springframework.batch.io.file.FieldSetMapper;
import org.springframework.batch.sample.domain.Player;
public class PlayerMapper implements FieldSetMapper {
public Object mapLine(FieldSet fs) {
if(fs == null){
return null;
}
Player player = new Player();
player.setID(fs.readString("ID"));
player.setLastName(fs.readString("lastName"));
player.setFirstName(fs.readString("firstName"));
player.setPosition(fs.readString("position"));
player.setDebutYear(fs.readInt("debutYear"));
player.setBirthYear(fs.readInt("birthYear"));
return player;
}
}

View File

@@ -18,23 +18,23 @@ package org.springframework.batch.sample.mapping;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.batch.sample.domain.NflPlayerSummary;
import org.springframework.batch.sample.domain.PlayerSummary;
import org.springframework.jdbc.core.RowMapper;
/**
* RowMapper used to map a ResultSet to a (@link NflPlayerSummary)
* RowMapper used to map a ResultSet to a (@link PlayerSummary)
*
* @author Lucas Ward
*
*/
public class NflPlayerSummaryMapper implements RowMapper {
public class PlayerSummaryMapper implements RowMapper {
/* (non-Javadoc)
* @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
*/
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
NflPlayerSummary summary = new NflPlayerSummary();
PlayerSummary summary = new PlayerSummary();
summary.setId(rs.getString(1));
summary.setYear(rs.getInt(2));

View File

@@ -12,7 +12,7 @@
<bean parent="stepScope" />
<bean parent="jobConfigurationRegistryBeanPostProcessor" />
<bean id="nflJob"
<bean id="footballJob"
class="org.springframework.batch.core.configuration.JobConfiguration">
<property name="restartable" value="true" />
<property name="startLimit" value="100" />
@@ -36,10 +36,10 @@
</property>
<property name="itemProcessor">
<bean
class="org.springframework.batch.sample.item.processor.NflPlayerItemProcessor">
<property name="nflPlayerDao">
class="org.springframework.batch.sample.item.processor.PlayerItemProcessor">
<property name="playerDao">
<bean
class="org.springframework.batch.sample.dao.SqlNflPlayerDao">
class="org.springframework.batch.sample.dao.SqlPlayerDao">
<property name="dataSource"
ref="dataSource" />
</bean>
@@ -69,7 +69,7 @@
class="org.springframework.batch.item.processor.ItemWriterItemProcessor">
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.dao.SqlNflGameDao">
class="org.springframework.batch.sample.dao.SqlGameDao">
<property name="dataSource"
ref="dataSource" />
</bean>
@@ -99,7 +99,7 @@
class="org.springframework.batch.item.processor.ItemWriterItemProcessor">
<property name="itemWriter">
<bean
class="org.springframework.batch.sample.dao.SqlNflPlayerSummaryDao">
class="org.springframework.batch.sample.dao.SqlPlayerSummaryDao">
<property name="dataSource"
ref="dataSource" />
</bean>
@@ -118,7 +118,7 @@
<property name="resource">
<bean
class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="data/nfljob/input/player.csv" />
<constructor-arg value="data/footballjob/input/player.csv" />
</bean>
</property>
<property name="tokenizer">
@@ -130,7 +130,7 @@
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.sample.mapping.NflPlayerMapper" />
class="org.springframework.batch.sample.mapping.PlayerMapper" />
</property>
</bean>
@@ -139,7 +139,7 @@
<property name="resource">
<bean
class="org.springframework.core.io.ClassPathResource">
<constructor-arg value="data/nfljob/input/games.csv" />
<constructor-arg value="data/footballjob/input/games.csv" />
</bean>
</property>
<property name="tokenizer">
@@ -151,7 +151,7 @@
</property>
<property name="fieldSetMapper">
<bean
class="org.springframework.batch.sample.mapping.NflGameMapper" />
class="org.springframework.batch.sample.mapping.GameMapper" />
</property>
</bean>
@@ -160,7 +160,7 @@
<property name="dataSource" ref="dataSource" />
<property name="mapper">
<bean
class="org.springframework.batch.sample.mapping.NflPlayerSummaryMapper" />
class="org.springframework.batch.sample.mapping.PlayerSummaryMapper" />
</property>
<property name="sql">
<value>

View File

@@ -1,9 +1,9 @@
package org.springframework.batch.sample;
public class NflJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
public class FootballJobFunctionalTests extends AbstractValidatingBatchLauncherTests {
protected String[] getConfigLocations() {
return new String[] {"jobs/nfljob.xmlXXX"};
return new String[] {"jobs/footballJob.xml"};
}
protected void validatePostConditions() throws Exception {

View File

@@ -29,7 +29,7 @@ public class TaskExecutorLauncher {
// Paths to individual job configurations. Each one must include the
// step scope and the jobConfigurationRegistryBeanPostProcessor.
final String[] paths = new String[] { "jobs/adhocLoopJob.xml",
"jobs/nflJob.xml" };
"jobs/footballJob.xml" };
// The simple execution environment will be used as a parent
// context for each of the job contexts. The standard version of this

View File

@@ -18,7 +18,7 @@ package org.springframework.batch.sample.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.batch.sample.domain.NflGame;
import org.springframework.batch.sample.domain.Game;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
@@ -26,11 +26,11 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
* @author Lucas Ward
*
*/
public class SqlNflGameDaoIntegrationTests extends
public class SqlGameDaoIntegrationTests extends
AbstractTransactionalDataSourceSpringContextTests {
SqlNflGameDao gameDao;
NflGame game = new NflGame();
SqlGameDao gameDao;
Game game = new Game();
protected String[] getConfigLocations() {
return new String[]{"data-source-context.xml"};
@@ -39,7 +39,7 @@ public class SqlNflGameDaoIntegrationTests extends
protected void onSetUpBeforeTransaction() throws Exception {
super.onSetUpBeforeTransaction();
gameDao = new SqlNflGameDao();
gameDao = new SqlGameDao();
gameDao.setJdbcTemplate(getJdbcTemplate());
game.setId("AbduKa00");
@@ -63,11 +63,11 @@ public class SqlNflGameDaoIntegrationTests extends
gameDao.write(game);
NflGame tempGame = (NflGame)getJdbcTemplate().queryForObject("SELECT * FROM GAMES", new NflGameRowMapper());
Game tempGame = (Game)getJdbcTemplate().queryForObject("SELECT * FROM GAMES", new GameRowMapper());
assertEquals(tempGame, game);
}
public static class NflGameRowMapper implements RowMapper {
public static class GameRowMapper implements RowMapper {
public Object mapRow(ResultSet rs, int arg1) throws SQLException{
@@ -75,24 +75,24 @@ public class SqlNflGameDaoIntegrationTests extends
return null;
}
NflGame nflGame = new NflGame();
nflGame.setId(rs.getString("PLAYER_ID"));
nflGame.setYear(rs.getInt("year"));
nflGame.setTeam(rs.getString("team"));
nflGame.setWeek(rs.getInt("week"));
nflGame.setOpponent(rs.getString("opponent"));
nflGame.setCompletes(rs.getInt("completes"));
nflGame.setAttempts(rs.getInt("attempts"));
nflGame.setPassingYards(rs.getInt("passing_Yards"));
nflGame.setPassingTd(rs.getInt("passing_Td"));
nflGame.setInterceptions(rs.getInt("interceptions"));
nflGame.setRushes(rs.getInt("rushes"));
nflGame.setRushYards(rs.getInt("rush_Yards"));
nflGame.setReceptions(rs.getInt("receptions"));
nflGame.setReceptionYards(rs.getInt("receptions_Yards"));
nflGame.setTotalTd(rs.getInt("total_Td"));
Game game = new Game();
game.setId(rs.getString("PLAYER_ID"));
game.setYear(rs.getInt("year"));
game.setTeam(rs.getString("team"));
game.setWeek(rs.getInt("week"));
game.setOpponent(rs.getString("opponent"));
game.setCompletes(rs.getInt("completes"));
game.setAttempts(rs.getInt("attempts"));
game.setPassingYards(rs.getInt("passing_Yards"));
game.setPassingTd(rs.getInt("passing_Td"));
game.setInterceptions(rs.getInt("interceptions"));
game.setRushes(rs.getInt("rushes"));
game.setRushYards(rs.getInt("rush_Yards"));
game.setReceptions(rs.getInt("receptions"));
game.setReceptionYards(rs.getInt("receptions_Yards"));
game.setTotalTd(rs.getInt("total_Td"));
return nflGame;
return game;
}
}
}

View File

@@ -6,7 +6,7 @@ package org.springframework.batch.sample.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.batch.sample.domain.NflPlayer;
import org.springframework.batch.sample.domain.Player;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
@@ -14,10 +14,10 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
* @author Lucas Ward
*
*/
public class SqlNflPlayerDaoIntegrationTests extends AbstractTransactionalDataSourceSpringContextTests {
public class SqlPlayerDaoIntegrationTests extends AbstractTransactionalDataSourceSpringContextTests {
private SqlNflPlayerDao playerDao;
private NflPlayer player;
private SqlPlayerDao playerDao;
private Player player;
private static final String GET_PLAYER = "SELECT * from PLAYERS";
protected String[] getConfigLocations() {
@@ -29,10 +29,10 @@ public class SqlNflPlayerDaoIntegrationTests extends AbstractTransactionalDataSo
// TODO Auto-generated method stub
super.onSetUpBeforeTransaction();
playerDao = new SqlNflPlayerDao();
playerDao = new SqlPlayerDao();
playerDao.setJdbcTemplate(this.jdbcTemplate);
player = new NflPlayer();
player = new Player();
player.setID("AKFJDL00");
player.setFirstName("John");
player.setLastName("Doe");

View File

@@ -16,8 +16,8 @@
package org.springframework.batch.sample.dao;
import org.springframework.batch.sample.domain.NflPlayerSummary;
import org.springframework.batch.sample.mapping.NflPlayerSummaryMapper;
import org.springframework.batch.sample.domain.PlayerSummary;
import org.springframework.batch.sample.mapping.PlayerSummaryMapper;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
@@ -25,11 +25,11 @@ import org.springframework.test.AbstractTransactionalDataSourceSpringContextTest
* @author Lucas Ward
*
*/
public class SqlNflPlayerSummaryDaoIntegrationTests extends
public class SqlPlayerSummaryDaoIntegrationTests extends
AbstractTransactionalDataSourceSpringContextTests {
SqlNflPlayerSummaryDao playerSummaryDao;
NflPlayerSummary summary;
SqlPlayerSummaryDao playerSummaryDao;
PlayerSummary summary;
protected String[] getConfigLocations() {
return new String[] { "data-source-context.xml" };
@@ -38,10 +38,10 @@ public class SqlNflPlayerSummaryDaoIntegrationTests extends
protected void onSetUpBeforeTransaction() throws Exception {
super.onSetUpBeforeTransaction();
playerSummaryDao = new SqlNflPlayerSummaryDao();
playerSummaryDao = new SqlPlayerSummaryDao();
playerSummaryDao.setJdbcTemplate(getJdbcTemplate());
summary = new NflPlayerSummary();
summary = new PlayerSummary();
summary.setId("AikmTr00");
summary.setYear(1997);
summary.setCompletes(294);
@@ -60,9 +60,9 @@ public class SqlNflPlayerSummaryDaoIntegrationTests extends
playerSummaryDao.write(summary);
NflPlayerSummary testSummary = (NflPlayerSummary) getJdbcTemplate()
PlayerSummary testSummary = (PlayerSummary) getJdbcTemplate()
.queryForObject("SELECT * FROM PLAYER_SUMMARY",
new NflPlayerSummaryMapper());
new PlayerSummaryMapper());
assertEquals(testSummary, summary);
}