Commit 6e5b67ae authored by psakac's avatar psakac
Browse files

Added lat, lon to bank_branch

parent ecd7029c
......@@ -11,6 +11,9 @@ public class BankBranch {
private String city;
private String lat;
private String lon;
public Long getId() {
return id;
......@@ -43,4 +46,20 @@ public class BankBranch {
public void setCity(String city) {
this.city = city;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getLon() {
return lon;
}
public void setLon(String lon) {
this.lon = lon;
}
}
......@@ -22,7 +22,9 @@ public class SQLBankBranchRepository implements BankBranchRepository {
"[bank_branch].[id] AS [id_bb], " +
"[bank_branch].[address] AS [address_bb], " +
"[bank_branch].[city] AS [city_bb], " +
"[bank_branch].[zip] AS [zip_bb] " +
"[bank_branch].[zip] AS [zip_bb], " +
"[bank_branch].[lat] AS [lat_bb], " +
"[bank_branch].[lon] AS [lon_bb] " +
"FROM [bank_branch] WHERE id = ?";
try{
return jdbcTemplate.queryForObject(sql, new Object[] {id}, new BankBranchRowMapper());
......@@ -37,15 +39,18 @@ public class SQLBankBranchRepository implements BankBranchRepository {
"[bank_branch].[id] AS [id_bb], " +
"[bank_branch].[address] AS [address_bb], " +
"[bank_branch].[city] AS [city_bb], " +
"[bank_branch].[zip] AS [zip_bb] " +
"[bank_branch].[zip] AS [zip_bb], " +
"[bank_branch].[lat] AS [lat_bb], " +
"[bank_branch].[lon] AS [lon_bb] " +
"FROM [bank_branch]";
return jdbcTemplate.query(sql, new BankBranchRowMapper());
}
@Override
public void createBankBranch(BankBranch bankBranch) {
final String sql = "INSERT INTO [bank_branch] (address, zip, city) VALUES (?, ?, ?)";
jdbcTemplate.update(sql, bankBranch.getAddress(), bankBranch.getZip(), bankBranch.getCity());
final String sql = "INSERT INTO [bank_branch] (address, zip, city, lat, lon) VALUES (?, ?, ?, ?, ?)";
jdbcTemplate.update(sql, bankBranch.getAddress(), bankBranch.getZip(), bankBranch.getCity(),
bankBranch.getLat(), bankBranch.getLon());
}
@Override
......
......@@ -31,7 +31,9 @@ public class SQLRobberyEventRepository implements RobberyEventRepository {
"[bank_branch].[id] AS [id_bb], " +
"[bank_branch].[address] AS [address_bb], " +
"[bank_branch].[city] AS [city_bb], " +
"[bank_branch].[zip] AS [zip_bb] " +
"[bank_branch].[zip] AS [zip_bb], " +
"[bank_branch].[lat] AS [lat_bb], " +
"[bank_branch].[lon] AS [lon_bb] " +
"FROM [robbery_event] " +
"INNER JOIN [bank_branch] ON [robbery_event].[id_bank_branch] = [bank_branch].[id] " +
"ORDER BY [robbery_event].[timestamp]";
......@@ -53,7 +55,9 @@ public class SQLRobberyEventRepository implements RobberyEventRepository {
"[bank_branch].[id] AS [id_bb], " +
"[bank_branch].[address] AS [address_bb], " +
"[bank_branch].[city] AS [city_bb], " +
"[bank_branch].[zip] AS [zip_bb] " +
"[bank_branch].[zip] AS [zip_bb], " +
"[bank_branch].[lat] AS [lat_bb], " +
"[bank_branch].[lon] AS [lon_bb] " +
"FROM [robbery_event] " +
"INNER JOIN [bank_branch] ON [robbery_event].[id_bank_branch] = [bank_branch].[id] " +
"WHERE [robbery_event].[id_bank_branch] = ? " +
......
......@@ -15,6 +15,8 @@ public class BankBranchRowMapper implements RowMapper<BankBranch> {
bankBranch.setAddress(rs.getString("address_bb"));
bankBranch.setCity(rs.getString("city_bb"));
bankBranch.setZip(rs.getString("zip_bb"));
bankBranch.setLat(rs.getString("lat_bb"));
bankBranch.setLon(rs.getString("lon_bb"));
return bankBranch;
}
}
......@@ -10,6 +10,8 @@ CREATE TABLE [bank_branch] (
address VARCHAR(64) NOT NULL,
zip VARCHAR(64) NOT NULL,
city VARCHAR(64) NOT NULL,
lat VARCHAR(64) NOT NULL,
lon VARCHAR(64) NOT NULL,
PRIMARY KEY (id));
CREATE TABLE [robbery_event] (
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment