RESOLVED - issue BATCH-1407: Integration tests for core (including multi-threaded long running tests)
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.test.football;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
public class Game implements Serializable {
|
||||
|
||||
private String id;
|
||||
private int year;
|
||||
private String team;
|
||||
private int week;
|
||||
private String opponent;
|
||||
private int completes;
|
||||
private int attempts;
|
||||
private int passingYards;
|
||||
private int passingTd;
|
||||
private int interceptions;
|
||||
private int rushes;
|
||||
private int rushYards;
|
||||
private int receptions;
|
||||
private int receptionYards;
|
||||
private int totalTd;
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* @return the year
|
||||
*/
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
/**
|
||||
* @return the team
|
||||
*/
|
||||
public String getTeam() {
|
||||
return team;
|
||||
}
|
||||
/**
|
||||
* @return the week
|
||||
*/
|
||||
public int getWeek() {
|
||||
return week;
|
||||
}
|
||||
/**
|
||||
* @return the opponent
|
||||
*/
|
||||
public String getOpponent() {
|
||||
return opponent;
|
||||
}
|
||||
/**
|
||||
* @return the completes
|
||||
*/
|
||||
public int getCompletes() {
|
||||
return completes;
|
||||
}
|
||||
/**
|
||||
* @return the attempts
|
||||
*/
|
||||
public int getAttempts() {
|
||||
return attempts;
|
||||
}
|
||||
/**
|
||||
* @return the passingYards
|
||||
*/
|
||||
public int getPassingYards() {
|
||||
return passingYards;
|
||||
}
|
||||
/**
|
||||
* @return the passingTd
|
||||
*/
|
||||
public int getPassingTd() {
|
||||
return passingTd;
|
||||
}
|
||||
/**
|
||||
* @return the interceptions
|
||||
*/
|
||||
public int getInterceptions() {
|
||||
return interceptions;
|
||||
}
|
||||
/**
|
||||
* @return the rushes
|
||||
*/
|
||||
public int getRushes() {
|
||||
return rushes;
|
||||
}
|
||||
/**
|
||||
* @return the rushYards
|
||||
*/
|
||||
public int getRushYards() {
|
||||
return rushYards;
|
||||
}
|
||||
/**
|
||||
* @return the receptions
|
||||
*/
|
||||
public int getReceptions() {
|
||||
return receptions;
|
||||
}
|
||||
/**
|
||||
* @return the receptionYards
|
||||
*/
|
||||
public int getReceptionYards() {
|
||||
return receptionYards;
|
||||
}
|
||||
/**
|
||||
* @return the totalTd
|
||||
*/
|
||||
public int getTotalTd() {
|
||||
return totalTd;
|
||||
}
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
/**
|
||||
* @param year the year to set
|
||||
*/
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
/**
|
||||
* @param team the team to set
|
||||
*/
|
||||
public void setTeam(String team) {
|
||||
this.team = team;
|
||||
}
|
||||
/**
|
||||
* @param week the week to set
|
||||
*/
|
||||
public void setWeek(int week) {
|
||||
this.week = week;
|
||||
}
|
||||
/**
|
||||
* @param opponent the opponent to set
|
||||
*/
|
||||
public void setOpponent(String opponent) {
|
||||
this.opponent = opponent;
|
||||
}
|
||||
/**
|
||||
* @param completes the completes to set
|
||||
*/
|
||||
public void setCompletes(int completes) {
|
||||
this.completes = completes;
|
||||
}
|
||||
/**
|
||||
* @param attempts the attempts to set
|
||||
*/
|
||||
public void setAttempts(int attempts) {
|
||||
this.attempts = attempts;
|
||||
}
|
||||
/**
|
||||
* @param passingYards the passingYards to set
|
||||
*/
|
||||
public void setPassingYards(int passingYards) {
|
||||
this.passingYards = passingYards;
|
||||
}
|
||||
/**
|
||||
* @param passingTd the passingTd to set
|
||||
*/
|
||||
public void setPassingTd(int passingTd) {
|
||||
this.passingTd = passingTd;
|
||||
}
|
||||
/**
|
||||
* @param interceptions the interceptions to set
|
||||
*/
|
||||
public void setInterceptions(int interceptions) {
|
||||
this.interceptions = interceptions;
|
||||
}
|
||||
/**
|
||||
* @param rushes the rushes to set
|
||||
*/
|
||||
public void setRushes(int rushes) {
|
||||
this.rushes = rushes;
|
||||
}
|
||||
/**
|
||||
* @param rushYards the rushYards to set
|
||||
*/
|
||||
public void setRushYards(int rushYards) {
|
||||
this.rushYards = rushYards;
|
||||
}
|
||||
/**
|
||||
* @param receptions the receptions to set
|
||||
*/
|
||||
public void setReceptions(int receptions) {
|
||||
this.receptions = receptions;
|
||||
}
|
||||
/**
|
||||
* @param receptionYards the receptionYards to set
|
||||
*/
|
||||
public void setReceptionYards(int receptionYards) {
|
||||
this.receptionYards = receptionYards;
|
||||
}
|
||||
/**
|
||||
* @param totalTd the totalTd to set
|
||||
*/
|
||||
public void setTotalTd(int totalTd) {
|
||||
this.totalTd = totalTd;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
|
||||
return "Game: ID=" + id + " " + team + " vs. " + opponent +
|
||||
" - " + year;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.test.football;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Player implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String lastName;
|
||||
private String firstName;
|
||||
private String position;
|
||||
private int birthYear;
|
||||
private int debutYear;
|
||||
|
||||
public String toString() {
|
||||
|
||||
return "PLAYER:id=" + id + ",Last Name=" + lastName +
|
||||
",First Name=" + firstName + ",Position=" + position +
|
||||
",Birth Year=" + birthYear + ",DebutYear=" +
|
||||
debutYear;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
public int getBirthYear() {
|
||||
return birthYear;
|
||||
}
|
||||
public int getDebutYear() {
|
||||
return debutYear;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
public void setPosition(String position) {
|
||||
this.position = position;
|
||||
}
|
||||
public void setBirthYear(int birthYear) {
|
||||
this.birthYear = birthYear;
|
||||
}
|
||||
public void setDebutYear(int debutYear) {
|
||||
this.debutYear = debutYear;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.test.football;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for writing {@link Player} objects to arbitrary output.
|
||||
*/
|
||||
public interface PlayerDao {
|
||||
|
||||
void savePlayer(Player player);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.core.test.football;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
/**
|
||||
* Domain object representing the summary of a given Player's
|
||||
* year.
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class PlayerSummary {
|
||||
|
||||
private String id;
|
||||
private int year;
|
||||
private int completes;
|
||||
private int attempts;
|
||||
private int passingYards;
|
||||
private int passingTd;
|
||||
private int interceptions;
|
||||
private int rushes;
|
||||
private int rushYards;
|
||||
private int receptions;
|
||||
private int receptionYards;
|
||||
private int totalTd;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
public int getCompletes() {
|
||||
return completes;
|
||||
}
|
||||
public void setCompletes(int completes) {
|
||||
this.completes = completes;
|
||||
}
|
||||
public int getAttempts() {
|
||||
return attempts;
|
||||
}
|
||||
public void setAttempts(int attempts) {
|
||||
this.attempts = attempts;
|
||||
}
|
||||
public int getPassingYards() {
|
||||
return passingYards;
|
||||
}
|
||||
public void setPassingYards(int passingYards) {
|
||||
this.passingYards = passingYards;
|
||||
}
|
||||
public int getPassingTd() {
|
||||
return passingTd;
|
||||
}
|
||||
public void setPassingTd(int passingTd) {
|
||||
this.passingTd = passingTd;
|
||||
}
|
||||
public int getInterceptions() {
|
||||
return interceptions;
|
||||
}
|
||||
public void setInterceptions(int interceptions) {
|
||||
this.interceptions = interceptions;
|
||||
}
|
||||
public int getRushes() {
|
||||
return rushes;
|
||||
}
|
||||
public void setRushes(int rushes) {
|
||||
this.rushes = rushes;
|
||||
}
|
||||
public int getRushYards() {
|
||||
return rushYards;
|
||||
}
|
||||
public void setRushYards(int rushYards) {
|
||||
this.rushYards = rushYards;
|
||||
}
|
||||
public int getReceptions() {
|
||||
return receptions;
|
||||
}
|
||||
public void setReceptions(int receptions) {
|
||||
this.receptions = receptions;
|
||||
}
|
||||
public int getReceptionYards() {
|
||||
return receptionYards;
|
||||
}
|
||||
public void setReceptionYards(int receptionYards) {
|
||||
this.receptionYards = receptionYards;
|
||||
}
|
||||
public int getTotalTd() {
|
||||
return totalTd;
|
||||
}
|
||||
public void setTotalTd(int totalTd) {
|
||||
this.totalTd = totalTd;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return "Player Summary: ID=" + id + " Year=" + year + "[" + completes + ";" + attempts + ";" + passingYards +
|
||||
";" + passingTd + ";" + interceptions + ";" + rushes + ";" + rushYards + ";" + receptions +
|
||||
";" + receptionYards + ";" + totalTd;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj);
|
||||
}
|
||||
public int hashCode() {
|
||||
return HashCodeBuilder.reflectionHashCode(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.batch.repeat.RepeatContext;
|
||||
import org.springframework.batch.repeat.exception.ExceptionHandler;
|
||||
|
||||
public class FootballExceptionHandler implements ExceptionHandler {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(FootballExceptionHandler.class);
|
||||
|
||||
public void handleException(RepeatContext context, Throwable throwable)
|
||||
throws Throwable {
|
||||
|
||||
if (!(throwable instanceof NumberFormatException)) {
|
||||
throw throwable;
|
||||
} else {
|
||||
logger.error("Number Format Exception!", throwable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import org.springframework.batch.core.test.football.Game;
|
||||
import org.springframework.batch.item.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.item.file.transform.FieldSet;
|
||||
|
||||
public class GameFieldSetMapper implements FieldSetMapper<Game> {
|
||||
|
||||
public Game mapFieldSet(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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.test.football.Game;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||
|
||||
public class JdbcGameDao extends SimpleJdbcDaoSupport implements ItemWriter<Game> {
|
||||
|
||||
private SimpleJdbcInsert insertGame;
|
||||
|
||||
protected void initDao() throws Exception {
|
||||
super.initDao();
|
||||
insertGame = new SimpleJdbcInsert(getDataSource()).withTableName("GAMES").usingColumns("player_id", "year_no",
|
||||
"team", "week", "opponent", " completes", "attempts", "passing_yards", "passing_td", "interceptions",
|
||||
"rushes", "rush_yards", "receptions", "receptions_yards", "total_td");
|
||||
}
|
||||
|
||||
public void write(List<? extends Game> games) {
|
||||
|
||||
for (Game game : games) {
|
||||
|
||||
SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()).addValue(
|
||||
"year_no", game.getYear()).addValue("team", game.getTeam()).addValue("week", game.getWeek())
|
||||
.addValue("opponent", game.getOpponent()).addValue("completes", game.getCompletes()).addValue(
|
||||
"attempts", game.getAttempts()).addValue("passing_yards", game.getPassingYards()).addValue(
|
||||
"passing_td", game.getPassingTd()).addValue("interceptions", game.getInterceptions())
|
||||
.addValue("rushes", game.getRushes()).addValue("rush_yards", game.getRushYards()).addValue(
|
||||
"receptions", game.getReceptions()).addValue("receptions_yards", game.getReceptionYards())
|
||||
.addValue("total_td", game.getTotalTd());
|
||||
this.insertGame.execute(values);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import org.springframework.batch.core.test.football.Player;
|
||||
import org.springframework.batch.core.test.football.PlayerDao;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class JdbcPlayerDao extends SimpleJdbcDaoSupport implements PlayerDao {
|
||||
|
||||
public static final String INSERT_PLAYER =
|
||||
"INSERT into PLAYERS (player_id, last_name, first_name, pos, year_of_birth, year_drafted)" +
|
||||
" values (:id, :lastName, :firstName, :position, :birthYear, :debutYear)";
|
||||
|
||||
public void savePlayer(Player player) {
|
||||
|
||||
getSimpleJdbcTemplate().update(INSERT_PLAYER,
|
||||
new BeanPropertySqlParameterSource(player));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.test.football.PlayerSummary;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport;
|
||||
|
||||
public class JdbcPlayerSummaryDao extends SimpleJdbcDaoSupport implements ItemWriter<PlayerSummary> {
|
||||
|
||||
private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID, YEAR_NO, COMPLETES, ATTEMPTS, PASSING_YARDS, PASSING_TD, "
|
||||
+ "INTERCEPTIONS, RUSHES, RUSH_YARDS, RECEPTIONS, RECEPTIONS_YARDS, TOTAL_TD) "
|
||||
+ "values(:id, :year, :completes, :attempts, :passingYards, :passingTd, "
|
||||
+ ":interceptions, :rushes, :rushYards, :receptions, :receptionYards, :totalTd)";
|
||||
|
||||
public void write(List<? extends PlayerSummary> summaries) {
|
||||
|
||||
for (PlayerSummary summary : summaries) {
|
||||
|
||||
MapSqlParameterSource args = new MapSqlParameterSource().addValue("id", summary.getId()).addValue("year",
|
||||
summary.getYear()).addValue("completes", summary.getCompletes()).addValue("attempts",
|
||||
summary.getAttempts()).addValue("passingYards", summary.getPassingYards()).addValue("passingTd",
|
||||
summary.getPassingTd()).addValue("interceptions", summary.getInterceptions()).addValue("rushes",
|
||||
summary.getRushes()).addValue("rushYards", summary.getRushYards()).addValue("receptions",
|
||||
summary.getReceptions()).addValue("receptionYards", summary.getReceptionYards()).addValue(
|
||||
"totalTd", summary.getTotalTd());
|
||||
|
||||
getSimpleJdbcTemplate().update(INSERT_SUMMARY, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import org.springframework.batch.core.test.football.Player;
|
||||
import org.springframework.batch.item.file.mapping.FieldSetMapper;
|
||||
import org.springframework.batch.item.file.transform.FieldSet;
|
||||
|
||||
public class PlayerFieldSetMapper implements FieldSetMapper<Player> {
|
||||
|
||||
public Player mapFieldSet(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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.batch.core.test.football.Player;
|
||||
import org.springframework.batch.core.test.football.PlayerDao;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
|
||||
public class PlayerItemWriter implements ItemWriter<Player> {
|
||||
|
||||
private PlayerDao playerDao;
|
||||
|
||||
public void write(List<? extends Player> players) throws Exception {
|
||||
for (Player player : players) {
|
||||
playerDao.savePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayerDao(PlayerDao playerDao) {
|
||||
this.playerDao = playerDao;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.core.test.football.PlayerSummary;
|
||||
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
|
||||
|
||||
/**
|
||||
* RowMapper used to map a ResultSet to a {@link PlayerSummary}
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class PlayerSummaryMapper implements ParameterizedRowMapper<PlayerSummary> {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
|
||||
*/
|
||||
public PlayerSummary mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
PlayerSummary summary = new PlayerSummary();
|
||||
|
||||
summary.setId(rs.getString(1));
|
||||
summary.setYear(rs.getInt(2));
|
||||
summary.setCompletes(rs.getInt(3));
|
||||
summary.setAttempts(rs.getInt(4));
|
||||
summary.setPassingYards(rs.getInt(5));
|
||||
summary.setPassingTd(rs.getInt(6));
|
||||
summary.setInterceptions(rs.getInt(7));
|
||||
summary.setRushes(rs.getInt(8));
|
||||
summary.setRushYards(rs.getInt(9));
|
||||
summary.setReceptions(rs.getInt(10));
|
||||
summary.setReceptionYards(rs.getInt(11));
|
||||
summary.setTotalTd(rs.getInt(12));
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2006-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.batch.sample.domain.football.internal;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.springframework.batch.core.test.football.PlayerSummary;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
/**
|
||||
* RowMapper used to map a ResultSet to a {@link PlayerSummary}
|
||||
*
|
||||
* @author Lucas Ward
|
||||
*
|
||||
*/
|
||||
public class PlayerSummaryRowMapper implements RowMapper {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.jdbc.core.RowMapper#mapRow(java.sql.ResultSet, int)
|
||||
*/
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
|
||||
PlayerSummary summary = new PlayerSummary();
|
||||
|
||||
summary.setId(rs.getString(1));
|
||||
summary.setYear(rs.getInt(2));
|
||||
summary.setCompletes(rs.getInt(3));
|
||||
summary.setAttempts(rs.getInt(4));
|
||||
summary.setPassingYards(rs.getInt(5));
|
||||
summary.setPassingTd(rs.getInt(6));
|
||||
summary.setInterceptions(rs.getInt(7));
|
||||
summary.setRushes(rs.getInt(8));
|
||||
summary.setRushYards(rs.getInt(9));
|
||||
summary.setReceptions(rs.getInt(10));
|
||||
summary.setReceptionYards(rs.getInt(11));
|
||||
summary.setTotalTd(rs.getInt(12));
|
||||
|
||||
return summary;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?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 http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<job id="footballJob" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="playerload" next="gameLoad">
|
||||
<tasklet>
|
||||
<chunk reader="playerFileItemReader" writer="playerWriter"
|
||||
commit-interval="${job.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.sample.domain.football.internal.PlayerItemWriter">
|
||||
<property name="playerDao">
|
||||
<bean class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerDao">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="gameWriter" class="org.springframework.batch.sample.domain.football.internal.JdbcGameDao">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="summaryWriter" class="org.springframework.batch.sample.domain.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.sample.domain.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.sample.domain.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.sample.domain.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.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="properties">
|
||||
<value>
|
||||
games.file.name=games-small.csv
|
||||
player.file.name=player-small.csv
|
||||
job.commit.interval=2
|
||||
</value>
|
||||
</property>
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,119 @@
|
||||
<?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 http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
|
||||
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<job id="parellelJob" xmlns="http://www.springframework.org/schema/batch">
|
||||
<step id="playerload" next="gameLoadParallel">
|
||||
<tasklet>
|
||||
<chunk reader="playerFileItemReader" writer="playerWriter"
|
||||
commit-interval="${job.commit.interval}" />
|
||||
</tasklet>
|
||||
</step>
|
||||
<step id="gameLoadParallel" next="playerSummarization">
|
||||
<tasklet task-executor="taskExecutor">
|
||||
<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="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
|
||||
<property name="corePoolSize" value="10"/>
|
||||
<property name="maxPoolSize" value="20"/>
|
||||
<property name="queueCapacity" value="0"/>
|
||||
</bean>
|
||||
|
||||
<bean id="playerWriter" class="org.springframework.batch.sample.domain.football.internal.PlayerItemWriter">
|
||||
<property name="playerDao">
|
||||
<bean class="org.springframework.batch.sample.domain.football.internal.JdbcPlayerDao">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="gameWriter" class="org.springframework.batch.sample.domain.football.internal.JdbcGameDao">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="summaryWriter" class="org.springframework.batch.sample.domain.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.sample.domain.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="saveState" value="false" />
|
||||
<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.sample.domain.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.sample.domain.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.beans.factory.config.PropertyPlaceholderConfigurer">
|
||||
<property name="properties">
|
||||
<value>
|
||||
games.file.name=games-small.csv
|
||||
player.file.name=player-small.csv
|
||||
job.commit.interval=2
|
||||
</value>
|
||||
</property>
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
|
||||
<property name="ignoreUnresolvablePlaceholders" value="true" />
|
||||
<property name="order" value="1" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@@ -1,18 +0,0 @@
|
||||
# Placeholders batch.*
|
||||
# for Derby:
|
||||
batch.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
|
||||
batch.jdbc.url=jdbc:derby:derby-home/test;create=true
|
||||
batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.schema=
|
||||
batch.jndi.name=
|
||||
batch.naming.factory.initial=
|
||||
batch.naming.provider.url=
|
||||
batch.schema.script=schema-derby.sql
|
||||
batch.business.schema.script=business-schema-derby.sql
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
|
||||
# Bean Properties for override
|
||||
# when not using sequences:
|
||||
incrementerParent.columnName=ID
|
||||
@@ -1,17 +0,0 @@
|
||||
# Placeholders batch.*
|
||||
# for HSQLDB:
|
||||
batch.jdbc.driver=org.hsqldb.jdbcDriver
|
||||
batch.jdbc.url=jdbc:hsqldb:mem:testdb;sql.enforce_strict_size=true
|
||||
# use this one for a separate server process so you can inspect the results
|
||||
# (or add it to system properties with -D to override at run time).
|
||||
# batch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples
|
||||
batch.jdbc.user=sa
|
||||
batch.jdbc.password=
|
||||
batch.jdbc.testWhileIdle=false
|
||||
batch.jdbc.validationQuery=
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-hsqldb.sql
|
||||
batch.business.schema.script=classpath:/business-schema-hsqldb.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer
|
||||
batch.database.incrementer.parent=columnIncrementerParent
|
||||
batch.grid.size=2
|
||||
@@ -1,19 +0,0 @@
|
||||
# Placeholders batch.*
|
||||
# for MySQL:
|
||||
batch.jdbc.driver=com.mysql.jdbc.Driver
|
||||
batch.jdbc.url=jdbc:mysql://localhost/test
|
||||
batch.jdbc.user=root
|
||||
batch.jdbc.password=root
|
||||
batch.schema=
|
||||
batch.jndi.name=
|
||||
batch.naming.factory.initial=
|
||||
batch.naming.provider.url=
|
||||
batch.schema.script=schema-mysql.sql
|
||||
batch.drop.script=schema-drop-mysql.sql
|
||||
batch.business.schema.script=business-schema-mysql.sql
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
|
||||
# Bean Properties for override
|
||||
# when not using sequences:
|
||||
incrementerParent.columnName=ID
|
||||
@@ -0,0 +1,96 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
DROP TABLE BATCH_STAGING_SEQ ;
|
||||
DROP TABLE TRADE_SEQ ;
|
||||
DROP TABLE CUSTOMER_SEQ ;
|
||||
DROP TABLE BATCH_STAGING ;
|
||||
DROP TABLE TRADE ;
|
||||
DROP TABLE CUSTOMER ;
|
||||
DROP TABLE PLAYERS ;
|
||||
DROP TABLE GAMES ;
|
||||
DROP TABLE PLAYER_SUMMARY ;
|
||||
DROP TABLE ERROR_LOG ;
|
||||
|
||||
-- Autogenerated: do not edit this file
|
||||
|
||||
CREATE TABLE CUSTOMER_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
INSERT INTO CUSTOMER_SEQ (ID) values (5);
|
||||
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
INSERT INTO BATCH_STAGING_SEQ (ID) values (0);
|
||||
CREATE TABLE TRADE_SEQ (ID BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, DUMMY VARCHAR(1));
|
||||
INSERT INTO TRADE_SEQ (ID) values (0);
|
||||
|
||||
CREATE TABLE BATCH_STAGING (
|
||||
ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
JOB_ID BIGINT NOT NULL,
|
||||
VALUE BLOB NOT NULL,
|
||||
PROCESSED CHAR(1) NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE TRADE (
|
||||
ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
VERSION BIGINT ,
|
||||
ISIN VARCHAR(45) NOT NULL,
|
||||
QUANTITY BIGINT ,
|
||||
PRICE DECIMAL(8,2) ,
|
||||
CUSTOMER VARCHAR(45)
|
||||
) ;
|
||||
|
||||
CREATE TABLE CUSTOMER (
|
||||
ID BIGINT NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
VERSION BIGINT ,
|
||||
NAME VARCHAR(45) ,
|
||||
CREDIT DECIMAL(10,2)
|
||||
) ;
|
||||
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (2, 0, 'customer2', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (3, 0, 'customer3', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (4, 0, 'customer4', 100000);
|
||||
|
||||
CREATE TABLE PLAYERS (
|
||||
PLAYER_ID CHAR(8) NOT NULL PRIMARY KEY,
|
||||
LAST_NAME VARCHAR(35) NOT NULL,
|
||||
FIRST_NAME VARCHAR(25) NOT NULL,
|
||||
POS VARCHAR(10) ,
|
||||
YEAR_OF_BIRTH BIGINT NOT NULL,
|
||||
YEAR_DRAFTED BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE GAMES (
|
||||
PLAYER_ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
TEAM CHAR(3) NOT NULL,
|
||||
WEEK BIGINT NOT NULL,
|
||||
OPPONENT CHAR(3) ,
|
||||
COMPLETES BIGINT ,
|
||||
ATTEMPTS BIGINT ,
|
||||
PASSING_YARDS BIGINT ,
|
||||
PASSING_TD BIGINT ,
|
||||
INTERCEPTIONS BIGINT ,
|
||||
RUSHES BIGINT ,
|
||||
RUSH_YARDS BIGINT ,
|
||||
RECEPTIONS BIGINT ,
|
||||
RECEPTIONS_YARDS BIGINT ,
|
||||
TOTAL_TD BIGINT
|
||||
) ;
|
||||
|
||||
CREATE TABLE PLAYER_SUMMARY (
|
||||
ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
COMPLETES BIGINT NOT NULL ,
|
||||
ATTEMPTS BIGINT NOT NULL ,
|
||||
PASSING_YARDS BIGINT NOT NULL ,
|
||||
PASSING_TD BIGINT NOT NULL ,
|
||||
INTERCEPTIONS BIGINT NOT NULL ,
|
||||
RUSHES BIGINT NOT NULL ,
|
||||
RUSH_YARDS BIGINT NOT NULL ,
|
||||
RECEPTIONS BIGINT NOT NULL ,
|
||||
RECEPTIONS_YARDS BIGINT NOT NULL ,
|
||||
TOTAL_TD BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE ERROR_LOG (
|
||||
JOB_NAME CHAR(20) ,
|
||||
STEP_NAME CHAR(20) ,
|
||||
MESSAGE VARCHAR(300) NOT NULL
|
||||
) ;
|
||||
@@ -0,0 +1,53 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
DROP TABLE PLAYERS IF EXISTS;
|
||||
DROP TABLE GAMES IF EXISTS;
|
||||
DROP TABLE PLAYER_SUMMARY IF EXISTS;
|
||||
DROP TABLE ERROR_LOG IF EXISTS;
|
||||
|
||||
CREATE TABLE PLAYERS (
|
||||
PLAYER_ID CHAR(8) NOT NULL PRIMARY KEY,
|
||||
LAST_NAME VARCHAR(35) NOT NULL,
|
||||
FIRST_NAME VARCHAR(25) NOT NULL,
|
||||
POS VARCHAR(10) ,
|
||||
YEAR_OF_BIRTH BIGINT NOT NULL,
|
||||
YEAR_DRAFTED BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE GAMES (
|
||||
PLAYER_ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
TEAM CHAR(3) NOT NULL,
|
||||
WEEK BIGINT NOT NULL,
|
||||
OPPONENT CHAR(3) ,
|
||||
COMPLETES BIGINT ,
|
||||
ATTEMPTS BIGINT ,
|
||||
PASSING_YARDS BIGINT ,
|
||||
PASSING_TD BIGINT ,
|
||||
INTERCEPTIONS BIGINT ,
|
||||
RUSHES BIGINT ,
|
||||
RUSH_YARDS BIGINT ,
|
||||
RECEPTIONS BIGINT ,
|
||||
RECEPTIONS_YARDS BIGINT ,
|
||||
TOTAL_TD BIGINT
|
||||
) ;
|
||||
|
||||
CREATE TABLE PLAYER_SUMMARY (
|
||||
ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
COMPLETES BIGINT NOT NULL ,
|
||||
ATTEMPTS BIGINT NOT NULL ,
|
||||
PASSING_YARDS BIGINT NOT NULL ,
|
||||
PASSING_TD BIGINT NOT NULL ,
|
||||
INTERCEPTIONS BIGINT NOT NULL ,
|
||||
RUSHES BIGINT NOT NULL ,
|
||||
RUSH_YARDS BIGINT NOT NULL ,
|
||||
RECEPTIONS BIGINT NOT NULL ,
|
||||
RECEPTIONS_YARDS BIGINT NOT NULL ,
|
||||
TOTAL_TD BIGINT NOT NULL
|
||||
) ;
|
||||
|
||||
CREATE TABLE ERROR_LOG (
|
||||
JOB_NAME CHAR(20) ,
|
||||
STEP_NAME CHAR(20) ,
|
||||
MESSAGE VARCHAR(300) NOT NULL
|
||||
) ;
|
||||
@@ -0,0 +1,96 @@
|
||||
-- Autogenerated: do not edit this file
|
||||
DROP TABLE IF EXISTS BATCH_STAGING_SEQ ;
|
||||
DROP TABLE IF EXISTS TRADE_SEQ ;
|
||||
DROP TABLE IF EXISTS CUSTOMER_SEQ ;
|
||||
DROP TABLE IF EXISTS BATCH_STAGING ;
|
||||
DROP TABLE IF EXISTS TRADE ;
|
||||
DROP TABLE IF EXISTS CUSTOMER ;
|
||||
DROP TABLE IF EXISTS PLAYERS ;
|
||||
DROP TABLE IF EXISTS GAMES ;
|
||||
DROP TABLE IF EXISTS PLAYER_SUMMARY ;
|
||||
DROP TABLE IF EXISTS ERROR_LOG ;
|
||||
|
||||
-- Autogenerated: do not edit this file
|
||||
|
||||
CREATE TABLE CUSTOMER_SEQ (ID BIGINT NOT NULL) type=MYISAM;
|
||||
INSERT INTO CUSTOMER_SEQ values(5);
|
||||
CREATE TABLE BATCH_STAGING_SEQ (ID BIGINT NOT NULL) type=MYISAM;
|
||||
INSERT INTO BATCH_STAGING_SEQ values(0);
|
||||
CREATE TABLE TRADE_SEQ (ID BIGINT NOT NULL) type=MYISAM;
|
||||
INSERT INTO TRADE_SEQ values(0);
|
||||
|
||||
CREATE TABLE BATCH_STAGING (
|
||||
ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
JOB_ID BIGINT NOT NULL,
|
||||
VALUE BLOB NOT NULL,
|
||||
PROCESSED CHAR(1) NOT NULL
|
||||
) type=InnoDB;
|
||||
|
||||
CREATE TABLE TRADE (
|
||||
ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
VERSION BIGINT ,
|
||||
ISIN VARCHAR(45) NOT NULL,
|
||||
QUANTITY BIGINT ,
|
||||
PRICE DECIMAL(8,2) ,
|
||||
CUSTOMER VARCHAR(45)
|
||||
) type=InnoDB;
|
||||
|
||||
CREATE TABLE CUSTOMER (
|
||||
ID BIGINT NOT NULL PRIMARY KEY ,
|
||||
VERSION BIGINT ,
|
||||
NAME VARCHAR(45) ,
|
||||
CREDIT DECIMAL(10,2)
|
||||
) type=InnoDB;
|
||||
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (1, 0, 'customer1', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (2, 0, 'customer2', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (3, 0, 'customer3', 100000);
|
||||
INSERT INTO CUSTOMER (ID, VERSION, NAME, CREDIT) VALUES (4, 0, 'customer4', 100000);
|
||||
|
||||
CREATE TABLE PLAYERS (
|
||||
PLAYER_ID CHAR(8) NOT NULL PRIMARY KEY,
|
||||
LAST_NAME VARCHAR(35) NOT NULL,
|
||||
FIRST_NAME VARCHAR(25) NOT NULL,
|
||||
POS VARCHAR(10) ,
|
||||
YEAR_OF_BIRTH BIGINT NOT NULL,
|
||||
YEAR_DRAFTED BIGINT NOT NULL
|
||||
) type=InnoDB;
|
||||
|
||||
CREATE TABLE GAMES (
|
||||
PLAYER_ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
TEAM CHAR(3) NOT NULL,
|
||||
WEEK BIGINT NOT NULL,
|
||||
OPPONENT CHAR(3) ,
|
||||
COMPLETES BIGINT ,
|
||||
ATTEMPTS BIGINT ,
|
||||
PASSING_YARDS BIGINT ,
|
||||
PASSING_TD BIGINT ,
|
||||
INTERCEPTIONS BIGINT ,
|
||||
RUSHES BIGINT ,
|
||||
RUSH_YARDS BIGINT ,
|
||||
RECEPTIONS BIGINT ,
|
||||
RECEPTIONS_YARDS BIGINT ,
|
||||
TOTAL_TD BIGINT
|
||||
) type=InnoDB;
|
||||
|
||||
CREATE TABLE PLAYER_SUMMARY (
|
||||
ID CHAR(8) NOT NULL,
|
||||
YEAR_NO BIGINT NOT NULL,
|
||||
COMPLETES BIGINT NOT NULL ,
|
||||
ATTEMPTS BIGINT NOT NULL ,
|
||||
PASSING_YARDS BIGINT NOT NULL ,
|
||||
PASSING_TD BIGINT NOT NULL ,
|
||||
INTERCEPTIONS BIGINT NOT NULL ,
|
||||
RUSHES BIGINT NOT NULL ,
|
||||
RUSH_YARDS BIGINT NOT NULL ,
|
||||
RECEPTIONS BIGINT NOT NULL ,
|
||||
RECEPTIONS_YARDS BIGINT NOT NULL ,
|
||||
TOTAL_TD BIGINT NOT NULL
|
||||
) type=InnoDB;
|
||||
|
||||
CREATE TABLE ERROR_LOG (
|
||||
JOB_NAME CHAR(20) ,
|
||||
STEP_NAME CHAR(20) ,
|
||||
MESSAGE VARCHAR(300) NOT NULL
|
||||
) type=InnoDB;
|
||||
Reference in New Issue
Block a user