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

rough towns trails list complete

parent 138afcb7
No related branches found
No related tags found
1 merge request!34Resolve "As a user, I would like a town specific page which shows all trails for that town so that I can easily see my progress"
......@@ -7,7 +7,6 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Location {
// private int locationID;
private String locationName;
......@@ -64,14 +63,6 @@ public class Location {
}
public Location(String locationName, String locationEmail, String locationDescription, String locationPlace, int locationTrailID, boolean locationApproved) {
this.locationName = locationName;
this.locationEmail = locationEmail;
this.locationDescription = locationDescription;
this.locationPlace = locationPlace;
this.locationTrailID = locationTrailID;
this.locationApproved = locationApproved;
}
public void setLocationName(String locationName) {
......
......@@ -6,4 +6,6 @@ import java.util.List;
public interface TrailsRepository {
List<Trail> getAllTrails();
String getTrailNameWithID(String trailsID);
int getTrailIDFromTrailName(String trailsName);
}
......@@ -35,5 +35,10 @@ public class TrailsRepositoryJDBC implements TrailsRepository {
}
@Override
public int getTrailIDFromTrailName(String trailsName){
return jdbc.queryForObject("SELECT trailID FROM trails WHERE trailName=?", Integer.class, trailsName);
}
}
......@@ -37,6 +37,47 @@ public class PlacesController {
return modelAndView;
}
@RequestMapping(value="/town", method= RequestMethod.POST)
public String sendHtmlFragmentTown(Model map) {
map.addAttribute("foo", "bar");
return "checkpoint/checkpoint";
}
@GetMapping("/towns/{town}")
public ModelAndView getResultBySearchKeyTowns(@PathVariable String town) {
List<TownWithTrails> townsList = placeRepo.getAllTownCoords();
List<Trail> trailslocations = trailsRepo.getAllTrails();
List<Trail> correctTrails = new ArrayList<>();
String townNamee="";
int indexTown=999;
for (int i=0;i<townsList.size();i++){
if (Objects.equals(townsList.get(i).getTownName(), town)){
indexTown=i;
townNamee=town;
}
}
if (indexTown!=999){
int townIDFromTable= placeRepo.getTownIDFromName(townNamee);
for (int i=0;i<trailslocations.size();i++){
int trailID = trailsRepo.getTrailIDFromTrailName(trailslocations.get(i).getTrailName());
if ((trailID>100)&&(trailID<200)){
correctTrails.add(trailslocations.get(i));
}
if ((trailID>200)&&(trailID<300)){
correctTrails.add(trailslocations.get(i));
}
if ((trailID>300)&&(trailID<400)){
correctTrails.add(trailslocations.get(i));
}
}
}
ModelAndView modelAndView= new ModelAndView("fragments/townsPageFrags :: townSection");
modelAndView.addObject("town", townsList.get(indexTown));
modelAndView.addObject("trails", correctTrails);
return modelAndView;
}
@GetMapping("/checkpoints")
public ModelAndView getLocationPages(){
......@@ -58,6 +99,8 @@ public class PlacesController {
@GetMapping("/checkpoints/{location}")
public ModelAndView getResultBySearchKeyLocation(@PathVariable String location) {
List<LocationsCoordinates> locCoords = reorderCoordsWRTLocations(placeRepo.getAllLocationCoords());
......
......@@ -17,6 +17,8 @@ public interface PlacesCoordinatesRepository {
Boolean checkIfCoordsAreWithinTownBoundary(LocationsCoordinates loc);
int getTownIDFromName(String townsName);
// List<Location> getFullApprovedLocations(JdbcTemplate aJdbc);
......
......@@ -162,8 +162,10 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
} return false; // if location outside boundary, return true won't function and it wil return false.
}
@Override
public int getTownIDFromName(String townsName){
return jdbc.queryForObject("SELECT townID FROM townswithtrails WHERE townName=?", Integer.class, townsName);
}
// Method used to approve and add locations with associated coordinates. List<Location> unapprovedLocations
// public void approveLocationAndAddCoords(String locationsName, Double latCoords, Double longCoords,JdbcTemplate jdbc) {
......
<!DOCTYPE html>
<html lang="en" th:fragment="townSection" class="townPageFrag">
<head>
<meta charset="UTF-8">
<title th:text="${town.getTownName()}"></title>
<link rel="stylesheet" th:href="@{/css/templatingstyle.css}">
<link rel="stylesheet" th:href="@{/css/locationPageFragsStyle.css}">
</head>
<body >
<header th:insert="~{/fragments/Templating.html::header}"></header>
<main>
<hr style="height:40px; visibility:hidden;" />
<hr style="height:40px; visibility:hidden;" />
</main>
<footer th:insert="~{/fragments/Templating.html::footer}"></footer>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Trails</title>
</head>
<body>
<main>
<H1>Caerphilly</H1>
<div th:each="location:${locations}">
<!--<!DOCTYPE html>-->
<!--<html lang="en">-->
<!--<head>-->
<!-- <meta charset="UTF-8">-->
<!-- <title>Trails</title>-->
<!--</head>-->
<!--<body>-->
<!--<main>-->
<!-- <H1>Caerphilly</H1>-->
<!-- <div th:each="location:${locations}">-->
<H2></H2>
<!-- <H2></H2>-->
<ul>
<li th:text="${location.getLocationPlace()}"></li>
</ul>
<!-- <ul>-->
<!-- <li th:text="${location.getLocationPlace()}"></li>-->
<!-- </ul>-->
......@@ -26,16 +26,16 @@
</div>
<!-- </div>-->
</main>
<!--</main>-->
</body>
</html>
\ No newline at end of file
<!--</body>-->
<!--</html>-->
\ No newline at end of file
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