Skip to content
Snippets Groups Projects
Commit 98d03e94 authored by Rhys Evans's avatar Rhys Evans
Browse files

Added foreign key to trails table. Expanded on trails table.

parent 70891095
No related branches found
No related tags found
1 merge request!40Resolve "As a user I would like to see a map containing all landmarks for a trail and a suggested path between them, so that I can easily follow the trail"
......@@ -7,7 +7,22 @@ import lombok.Data;
@Data
@AllArgsConstructor
public class Trail {
private int trailsId;
private String name;
private Boolean tru;
private String trailsId;
private String trailName;
private String trailNumber;
public String getTrailsId() {
return trailsId;
}
public String getTrailName() {
return trailName;
}
public String getTrailNumber() {
return trailNumber;
}
}
......@@ -17,9 +17,9 @@ public class TrailsRepositoryJDBC implements TrailsRepository {
}
private void settrailsMapper(){
trailMapper = (rs, i) -> new Trail(
rs.getInt("trailID"),
rs.getString("trailID"),
rs.getString("name"),
rs.getBoolean("tru")
rs.getString("trailNumber")
);
}
public List<Trail> getAllTrails(){
......
......@@ -57,7 +57,7 @@ public class PlacesController {
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
int locationID = 999;
int workAroundID=0;// otherwise cases errors e.g. null used. 999 unlikely to be used so safe until then
for (int i=0;i<locCoords.size();i++){ /// for loop iterating over coordinates table need to match coordinate index with lcoation index manually
for (int i=0;i<locCoords.size();i++){ /// for loop iterating over coordinates table need to match coordinate index with location index manually
locationIDIndex.add(locCoords.get(i).getLocationID()-1); // gets location ID and therefore location list index number
locationCoordsWorkaround.add(locations.get(locCoords.get(i).getLocationID()-1));
if ( (locations.get(locCoords.get(i).getLocationID() - 1).getLocationName().replace(' ', '-').trim().equals(location)) ){
......@@ -74,4 +74,8 @@ public class PlacesController {
return modelAndView;
}
/// Trail webpage mapping
}
......@@ -3,8 +3,11 @@ insert into users (email, name) value ('hannah@gmail.com', 'Hannah');
insert into users (email, name) value ('nigel@gmail.com', 'Nigel');
delete from trails;
insert into trails ( Name,tru) value ( 'Caerphilly Coffee Trail',false);
insert into trails ( Name,tru) value ( 'Penarth Dragon Trail',true);
insert into trails ( trailID, trailName, trailNumber) value ( 0101,'Caerphilly Castle Trail','0101');
insert into trails ( trailID, trailName, trailNumber) value ( 0102,'Caerphilly Pub Trail','0102');
insert into trails ( trailID, trailName, trailNumber) value ( 0103,'Caerphilly Heritage Trail','0103');
insert into trails ( trailID, trailName, trailNumber) value ( 0201,'Risca Heritage Trail','0201');
insert into trails ( trailID, trailName, trailNumber) value ( 0301,'Penarth Heritage Trail','0301');
delete from locations;
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, true);
......
drop table if exists locationCoordinates;
drop table if exists locations;
drop table if exists trails;
create table if not exists trails
(
trailID bigint auto_increment primary key,
name varchar(128),
tru boolean
trailID varchar(128) primary key,
trailName varchar(128),
trailNumber varchar(128)
) engine=InnoDB;
drop table if exists locationCoordinates;
drop table if exists locations;
create table if not exists locations
(
locationID bigint auto_increment primary key,
......@@ -16,6 +19,9 @@ create table if not exists locations
locationDescription longtext,
locationPlace varchar(255),
locationTrailID varchar(128),
Foreign Key (locationTrailID) REFERENCES trails(trailID)
ON DELETE CASCADE
ON UPDATE RESTRICT,
locationApproved boolean
) engine=InnoDB;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment