Skip to content
Snippets Groups Projects
Commit 1502d047 authored by Gabriel Copat's avatar Gabriel Copat
Browse files

Fixed checkpoints

parent 1f112eb1
No related branches found
No related tags found
1 merge request!36Resolve "As a user I want to be able to use the application on any device e.g. iPhone, iPad, Laptop"
......@@ -6,7 +6,7 @@ import lombok.Data;
@Data
@AllArgsConstructor
public class Location {
// private int locationID;
private long locationID;
private String locationName;
private String locationEmail;
private String locationDescription;
......
......@@ -28,7 +28,7 @@ public class LocationRepositoryJDBC implements LocationRepository {
private void setlocationMapper(){
locationMapper = (rs, i) -> new Location(
rs.getLong("locationID"),
rs.getString("locationName"),
rs.getString("locationEmail"),
rs.getString("locationDescription"),
......
//Holds variable data for the trails table
package Team5.SmartTowns.data;
import Team5.SmartTowns.placeswithcoordinates.PlacesCoordinatesRepository;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import java.io.File;
import java.util.List;
......@@ -15,6 +18,7 @@ public class Trail {
private String trailNumber;
private String imgPath;
public Trail(Long trailsId, String trailName, String trailNumber) {
this.trailsId = trailsId;
this.trailName = trailName;
......
......@@ -37,7 +37,7 @@ public class LandmarksController {
} else{
// converts valid response using Location constructor into a submittable format to the sql table
Location loc= new Location(landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
Location loc= new Location(landmarks.getLandmarkID(), landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
locationRepository.addLocation(loc); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home");
return modelAndView;
......
......@@ -18,6 +18,7 @@ import org.springframework.web.servlet.ModelAndView;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Controller
public class PlacesController {
......@@ -112,9 +113,20 @@ public class PlacesController {
break;}
}
ModelAndView modelAndView= new ModelAndView("fragments/trailsPageFrags :: trailsSection");
System.out.println(locCoords.get(0).getLocationID());
System.out.println(approvedLocations.get(0).getLocationID());
// locations[indexValue.index].getLocationTrailID()==trail.getTrailsId()}
final int trailIDFINAL = trailID;
List<Location> finalLocations = approvedLocations.stream()
.filter(loc -> Long.parseLong(loc.getLocationTrailID()) == trailslocations.get(trailIDFINAL).getTrailsId())
.toList();
System.out.println(finalLocations);
modelAndView.addObject("trail", trailslocations.get(trailID));
modelAndView.addObject("locCoords", locCoords);
modelAndView.addObject("locations", approvedLocations);
modelAndView.addObject("locations", finalLocations);
modelAndView.addObject("stickers", rewardsRepository.getAllStickersFromPack(1));
return modelAndView;
......
<!-- @thymesVar id="location" type="Team5.SmartTowns.data.Location" -->
<!DOCTYPE html>
<html lang="en" th:fragment="trailsSection" class="trailsPageFrag">
<head>
......@@ -93,10 +94,10 @@
</div>
<H3>Checkpoints:</H3>
<!-- With the trial name, we go through locations list to get -->
<div th:each="locationCoord, indexValue:${locCoords}" >
<div th:if="${locations[indexValue.index].getLocationTrailID()==trail.getTrailsId()}">
<div th:each="location:${locations}" >
<div>
<li id="checkpointList">
<div><a th:href="'/checkpoints/'+${locations[indexValue.index].getLocationName().replace(' ', '-')}" th:text="${locations[indexValue.index].getLocationName()}"></a></div>
<div><a th:href="'/checkpoints/'+${location.getLocationName().replace(' ', '-')}" th:text="${location.getLocationName()}"></a></div>
<ul></ul>
</li>
</div>
......
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