Skip to content

Commit

Permalink
path modified for json files
Browse files Browse the repository at this point in the history
  • Loading branch information
imertetsu committed Aug 13, 2024
1 parent 4e32b78 commit 3f5ad0a
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 8 deletions.
Binary file not shown.
Binary file modified build/classes/java/main/com/spacecraft/services/EventService.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion build/resources/main/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ spring.application.name=SpacecraftEvents
server.servlet.context-path=/api
server.port=8083

swagger.server.url=localhost:8083/api
swagger.server.url=http://localhost:8083/api

spring.output.ansi.enabled=ALWAYS
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
5 changes: 3 additions & 2 deletions src/main/java/com/spacecraft/services/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

Expand All @@ -22,9 +23,9 @@ public class EventService {
@PostConstruct
public void loadData() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Path path = Paths.get("src", "main", "java", "com", "spacecraft", "persistence", "events.json");
events = objectMapper.readValue(
Files.readAllBytes(Paths.get("src/main/java/com/spacecraft/persistence/events.json")),
new TypeReference<List<EventDTO>>() {}
Files.readAllBytes(path), new TypeReference<List<EventDTO>>() {}
);
for (EventDTO event : events) {
System.out.println(event);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/spacecraft/services/LatitudeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.spacecraft.dtos.EventDTO;
import com.spacecraft.dtos.LatitudeDTO;
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

Expand All @@ -21,9 +23,9 @@ public class LatitudeService {
@PostConstruct
public void loadData() throws IOException{
ObjectMapper objectMapper = new ObjectMapper();
Path path = Paths.get("src", "main", "java", "com", "spacecraft", "persistence", "latitudes.json");
latitudes = objectMapper.readValue(
Files.readAllBytes(Paths.get("src/main/java/com/spacecraft/persistence/latitudes.json")),
new TypeReference<List<LatitudeDTO>>() {}
Files.readAllBytes(path), new TypeReference<List<LatitudeDTO>>() {}
);
}
}
7 changes: 5 additions & 2 deletions src/main/java/com/spacecraft/services/LongitudeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.spacecraft.dtos.EventDTO;
import com.spacecraft.dtos.LongitudeDTO;
import jakarta.annotation.PostConstruct;
import lombok.Getter;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

Expand All @@ -21,9 +23,10 @@ public class LongitudeService {
@PostConstruct
public void loadData() throws IOException{
ObjectMapper objectMapper = new ObjectMapper();
Path path = Paths.get("src", "main", "java", "com", "spacecraft", "persistence", "longitudes.json");

longitudes = objectMapper.readValue(
Files.readAllBytes(Paths.get("src/main/java/com/spacecraft/persistence/longitudes.json")),
new TypeReference<List<LongitudeDTO>>() {}
Files.readAllBytes(path), new TypeReference<List<LongitudeDTO>>() {}
);
for (LongitudeDTO longitudeDTO: longitudes){
System.out.println(longitudeDTO);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ spring.application.name=SpacecraftEvents
server.servlet.context-path=/api
server.port=8083

swagger.server.url=localhost:8083/api
swagger.server.url=http://localhost:8083/api

spring.output.ansi.enabled=ALWAYS

0 comments on commit 3f5ad0a

Please sign in to comment.