From b756e9009be3fc6e32d110827202628508ba65db Mon Sep 17 00:00:00 2001 From: dernasherbrezon Date: Fri, 2 Aug 2024 17:28:56 +0100 Subject: [PATCH] output explicit satellite name sometimes TLE has temporary satellite name and explicit name is to provided separately. --- .../web/api/observation/ObservationLoad.java | 14 ++++++++------ .../resources/aausat4Observation/expected.json | 1 + 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/ru/r2cloud/web/api/observation/ObservationLoad.java b/src/main/java/ru/r2cloud/web/api/observation/ObservationLoad.java index 540f16a1..5bed3ac5 100644 --- a/src/main/java/ru/r2cloud/web/api/observation/ObservationLoad.java +++ b/src/main/java/ru/r2cloud/web/api/observation/ObservationLoad.java @@ -64,9 +64,15 @@ public ModelAndView doGet(IHTTPSession session) { LOG.info("not found: {} id: {}", satelliteId, id); return new NotFound(); } + Satellite satellite = satelliteDao.findById(entity.getSatelliteId()); + if (satellite == null) { + LOG.info("satellite not found: {}", entity.getSatelliteId()); + return new NotFound(); + } JsonObject json = entity.toJson(signed); + json.add("satelliteName", satellite.getName()); if (entity.getDataPath() != null) { - JsonArray beacons = convertBeacons(entity); + JsonArray beacons = convertBeacons(satellite, entity); if (beacons != null) { json.add("dataEntity", beacons); } @@ -76,11 +82,7 @@ public ModelAndView doGet(IHTTPSession session) { return result; } - private JsonArray convertBeacons(Observation entity) { - Satellite satellite = satelliteDao.findById(entity.getSatelliteId()); - if (satellite == null) { - return null; - } + private static JsonArray convertBeacons(Satellite satellite, Observation entity) { Transmitter transmitter = satellite.getById(entity.getTransmitterId()); if (transmitter == null) { return null; diff --git a/src/test/resources/aausat4Observation/expected.json b/src/test/resources/aausat4Observation/expected.json index e87c4158..f9b67025 100644 --- a/src/test/resources/aausat4Observation/expected.json +++ b/src/test/resources/aausat4Observation/expected.json @@ -2,6 +2,7 @@ "id": "1559942730784", "start": 1559942730839, "end": 1559942731040, + "satelliteName": "AAUSAT 4", "satellite": "41460", "transmitterId": "41460-0", "tle": {