From f5b370011bb91eb93fcb58dd344dc6f73b778619 Mon Sep 17 00:00:00 2001 From: Alvaro Date: Sat, 15 Mar 2025 17:29:17 +0100 Subject: [PATCH] Adding new entities -> Table views --- backend/.gitignore | 1 + .../miarma/contaminus/common/Constants.java | 8 + .../database/entities/DeviceCO.java | 64 ++++++++ .../database/entities/DeviceGPS.java | 69 +++++++++ .../entities/DeviceLatestValuesView.java | 140 ++++++++++++++++++ .../database/entities/DevicePollutionMap.java | 88 +++++++++++ .../entities/DeviceSensorHistory.java | 79 ++++++++++ .../database/entities/DeviceSensorValue.java | 129 ++++++++++++++++ .../database/entities/DeviceWeather.java | 72 +++++++++ .../server/LogicLayerAPIVerticle.java | 35 ++++- 10 files changed, 682 insertions(+), 3 deletions(-) create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceCO.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceGPS.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceLatestValuesView.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DevicePollutionMap.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorHistory.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorValue.java create mode 100644 backend/src/main/java/net/miarma/contaminus/database/entities/DeviceWeather.java diff --git a/backend/.gitignore b/backend/.gitignore index 89540d8..93faf13 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1 +1,2 @@ /dependency-reduced-pom.xml +/target/ diff --git a/backend/src/main/java/net/miarma/contaminus/common/Constants.java b/backend/src/main/java/net/miarma/contaminus/common/Constants.java index c3d9b3f..62be3d1 100644 --- a/backend/src/main/java/net/miarma/contaminus/common/Constants.java +++ b/backend/src/main/java/net/miarma/contaminus/common/Constants.java @@ -26,6 +26,14 @@ public class Constants { public static final String POST_ACTUATORS = API_PREFIX + "/actuators"; public static final String PUT_ACTUATOR_BY_ID = API_PREFIX + "/actuators/:actuatorId"; + public static final String GET_CO_BY_DEVICE_VIEW = API_PREFIX + "/v_co_by_device"; + public static final String GET_GPS_BY_DEVICE_VIEW = API_PREFIX + "/v_gps_by_device"; + public static final String GET_LATEST_VALUES_VIEW = API_PREFIX + "/v_latest_values"; + public static final String GET_POLLUTION_MAP_VIEW = API_PREFIX + "/v_pollution_map"; + public static final String GET_SENSOR_HISTORY_BY_DEVICE_VIEW = API_PREFIX + "/v_sensor_history_by_device"; + public static final String GET_SENSOR_VALUES_VIEW = API_PREFIX + "/v_sensor_values"; + public static final String GET_WEATHER_BY_DEVICE_VIEW = API_PREFIX + "/v_weather_by_device"; + /* Bussiness Logic API */ public static final String GET_GROUP_BY_ID = API_PREFIX + "/groups/:groupId"; public static final String GET_GROUP_DEVICES = API_PREFIX + "/groups/:groupId/devices"; diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceCO.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceCO.java new file mode 100644 index 0000000..2b86eea --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceCO.java @@ -0,0 +1,64 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_co_by_device") +public class DeviceCO { + int deviceId; + float carbonMonoxide; + long timestamp; + + public DeviceCO() {} + + public DeviceCO(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.carbonMonoxide = row.getFloat("carbonMonoxide"); + this.timestamp = row.getLong("timestamp"); + } + + public DeviceCO(int deviceId, float carbonMonoxide, long timestamp) { + super(); + this.deviceId = deviceId; + this.carbonMonoxide = carbonMonoxide; + this.timestamp = timestamp; + } + + public int getDeviceId() { + return deviceId; + } + + public float getCarbonMonoxide() { + return carbonMonoxide; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(carbonMonoxide, deviceId, timestamp); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceCO other = (DeviceCO) obj; + return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) + && deviceId == other.deviceId && timestamp == other.timestamp; + } + + @Override + public String toString() { + return "DeviceCO [deviceId=" + deviceId + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp + + "]"; + } +} \ No newline at end of file diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceGPS.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceGPS.java new file mode 100644 index 0000000..4d81157 --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceGPS.java @@ -0,0 +1,69 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_gps_by_device") +public class DeviceGPS { + int deviceId; + float lat; + float lon; + long timestamp; + + public DeviceGPS() {} + + public DeviceGPS(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.lat = row.getFloat("lat"); + this.lon = row.getFloat("lon"); + this.timestamp = row.getLong("timestamp"); + } + + public DeviceGPS(int deviceId, long lat, long lon) { + super(); + this.deviceId = deviceId; + this.lat = lat; + this.lon = lon; + } + + public int getDeviceId() { + return deviceId; + } + + public float getLat() { + return lat; + } + + public float getLon() { + return lon; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(deviceId, lat, lon, timestamp); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceGPS other = (DeviceGPS) obj; + return deviceId == other.deviceId && Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) + && Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && timestamp == other.timestamp; + } + + @Override + public String toString() { + return "DeviceGPS [deviceId=" + deviceId + ", lat=" + lat + ", lon=" + lon + ", timestamp=" + timestamp + "]"; + } +} diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceLatestValuesView.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceLatestValuesView.java new file mode 100644 index 0000000..b7cb453 --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceLatestValuesView.java @@ -0,0 +1,140 @@ +package net.miarma.contaminus.database.entities; +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_latest_values") +public class DeviceLatestValuesView { + int deviceId; + int sensorId; + String sensorType; + String unit; + int sensorStatus; + long sensorTimestamp; + float temperature; + float humidity; + float carbonMonoxide; + float lat; + float lon; + long airValuesTimestamp; + + public DeviceLatestValuesView() {} + + public DeviceLatestValuesView(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.sensorId = row.getInteger("sensorId"); + this.sensorType = row.getString("sensorType"); + this.unit = row.getString("unit"); + this.sensorStatus = row.getInteger("sensorStatus"); + this.sensorTimestamp = row.getLong("sensorTimestamp"); + this.temperature = row.getFloat("temperature"); + this.humidity = row.getFloat("humidity"); + this.carbonMonoxide = row.getFloat("carbonMonoxide"); + this.lat = row.getFloat("lat"); + this.lon = row.getFloat("lon"); + this.airValuesTimestamp = row.getLong("airValuesTimestamp"); + } + + public DeviceLatestValuesView(int deviceId, int sensorId, String sensorType, String unit, int sensorStatus, + long sensorTimestamp, float temperature, float humidity, float carbonMonoxide, float lat, float lon, + long airValuesTimestamp) { + super(); + this.deviceId = deviceId; + this.sensorId = sensorId; + this.sensorType = sensorType; + this.unit = unit; + this.sensorStatus = sensorStatus; + this.sensorTimestamp = sensorTimestamp; + this.temperature = temperature; + this.humidity = humidity; + this.carbonMonoxide = carbonMonoxide; + this.lat = lat; + this.lon = lon; + this.airValuesTimestamp = airValuesTimestamp; + } + + public int getDeviceId() { + return deviceId; + } + + public int getSensorId() { + return sensorId; + } + + public String getSensorType() { + return sensorType; + } + + public String getUnit() { + return unit; + } + + public int getSensorStatus() { + return sensorStatus; + } + + public long getSensorTimestamp() { + return sensorTimestamp; + } + + public float getTemperature() { + return temperature; + } + + public float getHumidity() { + return humidity; + } + + public float getCarbonMonoxide() { + return carbonMonoxide; + } + + public float getLat() { + return lat; + } + + public float getLon() { + return lon; + } + + public long getAirValuesTimestamp() { + return airValuesTimestamp; + } + + @Override + public int hashCode() { + return Objects.hash(airValuesTimestamp, carbonMonoxide, deviceId, humidity, lat, lon, sensorId, sensorStatus, + sensorTimestamp, sensorType, temperature, unit); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceLatestValuesView other = (DeviceLatestValuesView) obj; + return airValuesTimestamp == other.airValuesTimestamp + && Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) + && deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) + && Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) + && Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && sensorId == other.sensorId + && sensorStatus == other.sensorStatus && sensorTimestamp == other.sensorTimestamp + && Objects.equals(sensorType, other.sensorType) + && Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) + && Objects.equals(unit, other.unit); + } + + @Override + public String toString() { + return "DeviceLatestValuesView [deviceId=" + deviceId + ", sensorId=" + sensorId + ", sensorType=" + sensorType + + ", unit=" + unit + ", sensorStatus=" + sensorStatus + ", sensorTimestamp=" + sensorTimestamp + + ", temperature=" + temperature + ", humidity=" + humidity + ", carbonMonoxide=" + carbonMonoxide + + ", lat=" + lat + ", lon=" + lon + ", airValuesTimestamp=" + airValuesTimestamp + "]"; + } + + +} diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DevicePollutionMap.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DevicePollutionMap.java new file mode 100644 index 0000000..b5aff20 --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DevicePollutionMap.java @@ -0,0 +1,88 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_pollution_map") +public class DevicePollutionMap { + int deviceId; + String deviceName; + float lat; + float lon; + float carbonMonoxide; + long timestamp; + + public DevicePollutionMap() {} + + public DevicePollutionMap(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.deviceName = row.getString("deviceName"); + this.lat = row.getFloat("lat"); + this.lon = row.getFloat("lon"); + this.carbonMonoxide = row.getFloat("carbonMonoxide"); + this.timestamp = row.getLong("timestamp"); + } + + public DevicePollutionMap(int deviceId, String deviceName, float lat, float lon, float carbonMonoxide, + long timestamp) { + super(); + this.deviceId = deviceId; + this.deviceName = deviceName; + this.lat = lat; + this.lon = lon; + this.carbonMonoxide = carbonMonoxide; + this.timestamp = timestamp; + } + + public int getDeviceId() { + return deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public float getLat() { + return lat; + } + + public float getLon() { + return lon; + } + + public float getCarbonMonoxide() { + return carbonMonoxide; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(carbonMonoxide, deviceId, deviceName, lat, lon, timestamp); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DevicePollutionMap other = (DevicePollutionMap) obj; + return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) + && deviceId == other.deviceId && Objects.equals(deviceName, other.deviceName) + && Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) + && Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && timestamp == other.timestamp; + } + + @Override + public String toString() { + return "DevicePollutionMap [deviceId=" + deviceId + ", deviceName=" + deviceName + ", lat=" + lat + ", lon=" + + lon + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp + "]"; + } +} \ No newline at end of file diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorHistory.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorHistory.java new file mode 100644 index 0000000..34f1d1e --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorHistory.java @@ -0,0 +1,79 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_sensor_history_by_device") +public class DeviceSensorHistory { + int deviceId; + String deviceName; + float value; + String valueType; + long timestamp; + + public DeviceSensorHistory() {} + + public DeviceSensorHistory(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.deviceName = row.getString("deviceName"); + this.value = row.getFloat("value"); + this.valueType = row.getString("valueType"); + this.timestamp = row.getLong("timestamp"); + } + + public DeviceSensorHistory(int deviceId, String deviceName, float value, String valueType, long timestamp) { + super(); + this.deviceId = deviceId; + this.deviceName = deviceName; + this.value = value; + this.valueType = valueType; + this.timestamp = timestamp; + } + + public int getDeviceId() { + return deviceId; + } + + public String getDeviceName() { + return deviceName; + } + + public float getValue() { + return value; + } + + public String getValueType() { + return valueType; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(deviceId, deviceName, timestamp, value, valueType); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceSensorHistory other = (DeviceSensorHistory) obj; + return deviceId == other.deviceId && Objects.equals(deviceName, other.deviceName) + && timestamp == other.timestamp && Float.floatToIntBits(value) == Float.floatToIntBits(other.value) + && Objects.equals(valueType, other.valueType); + } + + @Override + public String toString() { + return "DeviceSensorHistory [deviceId=" + deviceId + ", deviceName=" + deviceName + ", value=" + value + + ", valueType=" + valueType + ", timestamp=" + timestamp + "]"; + } +} diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorValue.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorValue.java new file mode 100644 index 0000000..39e2676 --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceSensorValue.java @@ -0,0 +1,129 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_sensor_values") +public class DeviceSensorValue { + int sensorId; + int deviceId; + String sensorType; + String unit; + int sensorStatus; + float temperature; + float humidity; + float carbonMonoxide; + float lat; + float lon; + long timestamp; + + public DeviceSensorValue() {} + + public DeviceSensorValue(Row row) { + this.sensorId = row.getInteger("sensorId"); + this.deviceId = row.getInteger("deviceId"); + this.sensorType = row.getString("sensorType"); + this.unit = row.getString("unit"); + this.sensorStatus = row.getInteger("sensorStatus"); + this.temperature = row.getFloat("temperature"); + this.humidity = row.getFloat("humidty"); + this.carbonMonoxide = row.getFloat("carbonMonoxide"); + this.lat = row.getFloat("lat"); + this.lon = row.getFloat("lon"); + this.timestamp = row.getLong("timestamp"); + } + + public DeviceSensorValue(int sensorId, int deviceId, String sensorType, String unit, int sensorStatus, + float temperature, float humidity, float carbonMonoxide, float lat, float lon, long timestamp) { + super(); + this.sensorId = sensorId; + this.deviceId = deviceId; + this.sensorType = sensorType; + this.unit = unit; + this.sensorStatus = sensorStatus; + this.temperature = temperature; + this.humidity = humidity; + this.carbonMonoxide = carbonMonoxide; + this.lat = lat; + this.lon = lon; + this.timestamp = timestamp; + } + + public int getSensorId() { + return sensorId; + } + + public int getDeviceId() { + return deviceId; + } + + public String getSensorType() { + return sensorType; + } + + public String getUnit() { + return unit; + } + + public int getSensorStatus() { + return sensorStatus; + } + + public float getTemperature() { + return temperature; + } + + public float getHumidity() { + return humidity; + } + + public float getCarbonMonoxide() { + return carbonMonoxide; + } + + public float getLat() { + return lat; + } + + public float getLon() { + return lon; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(carbonMonoxide, deviceId, humidity, lat, lon, sensorId, sensorStatus, sensorType, + temperature, timestamp, unit); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceSensorValue other = (DeviceSensorValue) obj; + return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) + && deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) + && Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) + && Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && sensorId == other.sensorId + && sensorStatus == other.sensorStatus && Objects.equals(sensorType, other.sensorType) + && Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) + && timestamp == other.timestamp && Objects.equals(unit, other.unit); + } + + @Override + public String toString() { + return "DeviceSensorValue [sensorId=" + sensorId + ", deviceId=" + deviceId + ", sensorType=" + sensorType + + ", unit=" + unit + ", sensorStatus=" + sensorStatus + ", temperature=" + temperature + ", humidity=" + + humidity + ", carbonMonoxide=" + carbonMonoxide + ", lat=" + lat + ", lon=" + lon + ", timestamp=" + + timestamp + "]"; + } +} diff --git a/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceWeather.java b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceWeather.java new file mode 100644 index 0000000..540ad8a --- /dev/null +++ b/backend/src/main/java/net/miarma/contaminus/database/entities/DeviceWeather.java @@ -0,0 +1,72 @@ +package net.miarma.contaminus.database.entities; + +import java.util.Objects; + +import io.vertx.sqlclient.Row; +import net.miarma.contaminus.common.Table; + +@Table("v_weather_by_device") +public class DeviceWeather { + int deviceId; + float temperature; + float humidity; + long timestamp; + + public DeviceWeather() {} + + public DeviceWeather(Row row) { + this.deviceId = row.getInteger("deviceId"); + this.temperature = row.getFloat("temperature"); + this.humidity = row.getFloat("humidity"); + this.timestamp = row.getLong("timestamp"); + } + + public DeviceWeather(int deviceId, float temperature, float humidity, long timestamp) { + super(); + this.deviceId = deviceId; + this.temperature = temperature; + this.humidity = humidity; + this.timestamp = timestamp; + } + + public int getDeviceId() { + return deviceId; + } + + public float getTemperature() { + return temperature; + } + + public float getHumidity() { + return humidity; + } + + public long getTimestamp() { + return timestamp; + } + + @Override + public int hashCode() { + return Objects.hash(deviceId, humidity, temperature, timestamp); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + DeviceWeather other = (DeviceWeather) obj; + return deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) + && Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) + && timestamp == other.timestamp; + } + + @Override + public String toString() { + return "DeviceWeather [deviceId=" + deviceId + ", temperature=" + temperature + ", humidity=" + humidity + + ", timestamp=" + timestamp + "]"; + } +} \ No newline at end of file diff --git a/backend/src/main/java/net/miarma/contaminus/server/LogicLayerAPIVerticle.java b/backend/src/main/java/net/miarma/contaminus/server/LogicLayerAPIVerticle.java index 57ccf98..102b07f 100644 --- a/backend/src/main/java/net/miarma/contaminus/server/LogicLayerAPIVerticle.java +++ b/backend/src/main/java/net/miarma/contaminus/server/LogicLayerAPIVerticle.java @@ -2,23 +2,35 @@ package net.miarma.contaminus.server; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Set; +import com.google.gson.Gson; + import io.vertx.core.AbstractVerticle; import io.vertx.core.Promise; import io.vertx.core.http.HttpMethod; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.client.WebClientOptions; import io.vertx.ext.web.handler.BodyHandler; import io.vertx.ext.web.handler.CorsHandler; import net.miarma.contaminus.common.ConfigManager; import net.miarma.contaminus.common.Constants; +import net.miarma.contaminus.database.entities.Device; +import net.miarma.contaminus.util.RestClientUtil; public class LogicLayerAPIVerticle extends AbstractVerticle { private ConfigManager configManager; - + private final Gson gson = new Gson(); + private RestClientUtil restClient; + public LogicLayerAPIVerticle() { this.configManager = ConfigManager.getInstance(); + WebClientOptions options = new WebClientOptions() + .setUserAgent("ContaminUS"); + this.restClient = new RestClientUtil(WebClient.create(vertx, options)); } @Override @@ -58,8 +70,25 @@ public class LogicLayerAPIVerticle extends AbstractVerticle { private void getGroupDevices(RoutingContext context) { - context.response().end("TODO"); - } + Integer groupId = Integer.parseInt(context.request().getParam("groupId")); + + Promise resultList = Promise.promise(); + resultList.future().onComplete(complete -> { + if(complete.succeeded()) { + List aux = Arrays.asList(complete.result()).stream() + .filter(d -> d.getGroupId() == groupId) + .toList(); + context.response() + .putHeader("content-type", "application/json; charset=utf-8") + .end(gson.toJson(aux)); + } else { + context.fail(500, complete.cause()); + } + }); + + this.restClient.getRequest(configManager.getDataApiPort(), configManager.getHost(), + Constants.GET_GROUP_DEVICES, Device[].class, resultList); + } private void getDeviceSensors(RoutingContext context) { context.response().end("TODO");