Skip to content

Commit

Permalink
Merge pull request #274 from SeC-Hikit/77-as-a-user-i-want-to-draw-a-…
Browse files Browse the repository at this point in the history
…simple-itinerary-1

#77 Adjusted conf, Added .gpx download
  • Loading branch information
loreV authored Mar 29, 2024
2 parents 891c562 + 146dc30 commit cd727d0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
8 changes: 5 additions & 3 deletions backend/src/main/java/org/sc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.sc.configuration.StartupChecker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -21,8 +20,11 @@ public class Main {
AppProperties.APP_NAME + " v" + AppProperties.DISPLAYED_VERSION + "\n" +
"-------------------------";

@Autowired
StartupChecker startupChecker;
final StartupChecker startupChecker;

public Main(StartupChecker startupChecker) {
this.startupChecker = startupChecker;
}

public static void main(String[] args) {
SpringApplication backend = new SpringApplication(Main.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public void init() {
configureDir(fileManagementUtil.getTrailStoragePath(), "Could not create trail folder");
configureDir(fileManagementUtil.getRawTrailStoragePath(), "Could not create raw trail folder");
configureDir(fileManagementUtil.getTrailGpxStoragePath(), "Could not create trail/gpx folder");
configureDir(fileManagementUtil.getCustomItineraryPath(), "Could not create trail/gpx folder");
configureDir(fileManagementUtil.getTrailKmlStoragePath(), "Could not create trail/kml folder");
configureDir(fileManagementUtil.getTrailPdfStoragePath(), "Could not create trail/pdf folder");
configureDir(fileManagementUtil.getTrailCsvStoragePath(), "Could not create trail/csv folder");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.sc.common.rest.CustomItineraryResultDto
import org.sc.data.validator.GeneralValidator
import org.sc.service.CustomItineraryService
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
Expand Down Expand Up @@ -37,8 +38,8 @@ class CustomItineraryController constructor(

@Operation(summary = "Download a gpx itinerary based on the calculated result")
@PostMapping("/itinerary-download")
fun downloadGpx(@RequestBody customItinerary: CustomItineraryResultDto): ByteArray {
return customItineraryService.exportGpx(customItinerary)
fun downloadGpx(@RequestBody customItinerary: CustomItineraryResultDto): ResponseEntity<ByteArray> {
return ResponseEntity.ok(customItineraryService.exportGpx(customItinerary))
}

}
7 changes: 4 additions & 3 deletions backend/src/main/java/org/sc/manager/TrailFileManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ class TrailFileManager @Autowired constructor(
).build()
val date = now()
val generatedFilename = "custom-itineary-${date.toEpochMilli()}.gpx"
gpxFileHandlerHelper.writeToFile(gpx, customItineraryStoredFiles)
return Files.readAllBytes(customItineraryStoredFiles
.resolve(File.separator + generatedFilename))
val resolvedSavePath = customItineraryStoredFiles
.resolve(generatedFilename)
gpxFileHandlerHelper.writeToFile(gpx, resolvedSavePath)
return Files.readAllBytes(resolvedSavePath)
}

private fun buildTrailGpx(creator: String, trail: TrailDto): GPX {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ spring.jackson.serialization.write_dates_as_timestamps=false

# Microservices
microservice.ert.localities.enabled=true
microservice.ert.events.enabled=
microservice.ert.events.enabled=true
microservice.ert.localities=http://localhost:8991/api/v1/locality
microservice.ert.municipality=http://localhost:8991/api/v1/municipality
microservice.ert.event=http://localhost:8991/api/v1/event

0 comments on commit cd727d0

Please sign in to comment.