1
0

Fixed errors in Business Logic API and finished it.

This commit is contained in:
Jose
2025-03-16 02:19:50 +01:00
parent 664aea42cd
commit e54f63ba74
17 changed files with 260 additions and 274 deletions

View File

@@ -9,10 +9,10 @@ import net.miarma.contaminus.util.DateParser;
@Table("actuators") @Table("actuators")
public class Actuator { public class Actuator {
private int actuatorId; private Integer actuatorId;
private int deviceId; private Integer deviceId;
private int status; private Integer status;
private long timestamp; private Long timestamp;
public Actuator() {} public Actuator() {}
@@ -23,7 +23,7 @@ public class Actuator {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public Actuator(int actuatorId, int deviceId, int status, long timestamp) { public Actuator(Integer actuatorId, Integer deviceId, Integer status, Long timestamp) {
super(); super();
this.actuatorId = actuatorId; this.actuatorId = actuatorId;
this.deviceId = deviceId; this.deviceId = deviceId;
@@ -31,35 +31,35 @@ public class Actuator {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getActuatorId() { public Integer getActuatorId() {
return actuatorId; return actuatorId;
} }
public void setActuatorId(int actuatorId) { public void setActuatorId(Integer actuatorId) {
this.actuatorId = actuatorId; this.actuatorId = actuatorId;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public void setDeviceId(int deviceId) { public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId; this.deviceId = deviceId;
} }
public int getStatus() { public Integer getStatus() {
return status; return status;
} }
public void setStatus(int status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
public void setTimestamp(long timestamp) { public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }

View File

@@ -9,10 +9,10 @@ import net.miarma.contaminus.util.DateParser;
@Table("co_values") @Table("co_values")
public class COValue { public class COValue {
private int valueId; private Integer valueId;
private int sensorId; private Integer sensorId;
private float value; private Float value;
private long timestamp; private Long timestamp;
public COValue() {} public COValue() {}
@@ -23,7 +23,7 @@ public class COValue {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public COValue(int valueId, int sensorId, float value, long timestamp) { public COValue(Integer valueId, Integer sensorId, Float value, Long timestamp) {
super(); super();
this.valueId = valueId; this.valueId = valueId;
this.sensorId = sensorId; this.sensorId = sensorId;
@@ -31,35 +31,35 @@ public class COValue {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getValueId() { public Integer getValueId() {
return valueId; return valueId;
} }
public void setValueId(int valueId) { public void setValueId(Integer valueId) {
this.valueId = valueId; this.valueId = valueId;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
public void setSensorId(int sensorId) { public void setSensorId(Integer sensorId) {
this.sensorId = sensorId; this.sensorId = sensorId;
} }
public float getValue() { public Float getValue() {
return value; return value;
} }
public void setValue(float value) { public void setValue(Float value) {
this.value = value; this.value = value;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
public void setTimestamp(long timestamp) { public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
@@ -77,9 +77,8 @@ public class COValue {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
COValue other = (COValue) obj; COValue other = (COValue) obj;
return sensorId == other.sensorId return Objects.equals(sensorId, other.sensorId) && Objects.equals(timestamp, other.timestamp)
&& Objects.equals(timestamp, other.timestamp) && Objects.equals(value, other.value) && Objects.equals(valueId, other.valueId);
&& Float.floatToIntBits(value) == Float.floatToIntBits(other.value) && valueId == other.valueId;
} }
@Override @Override
@@ -88,5 +87,7 @@ public class COValue {
+ timestamp + "]"; + timestamp + "]";
} }
} }

View File

@@ -1,15 +1,13 @@
package net.miarma.contaminus.database.entities; package net.miarma.contaminus.database.entities;
import java.util.Objects;
import io.vertx.sqlclient.Row; import io.vertx.sqlclient.Row;
import net.miarma.contaminus.common.Table; import net.miarma.contaminus.common.Table;
@Table("devices") @Table("devices")
public class Device { public class Device {
private int deviceId; private Integer deviceId;
private int groupId; private Integer groupId;
private String deviceName; private String deviceName;
public Device() {} public Device() {}
@@ -20,26 +18,26 @@ public class Device {
this.deviceName = row.getString("deviceName"); this.deviceName = row.getString("deviceName");
} }
public Device(int deviceId, int groupId, String deviceName) { public Device(Integer deviceId, Integer groupId, String deviceName) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.groupId = groupId; this.groupId = groupId;
this.deviceName = deviceName; this.deviceName = deviceName;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public void setDeviceId(int deviceId) { public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId; this.deviceId = deviceId;
} }
public int getGroupId() { public Integer getGroupId() {
return groupId; return groupId;
} }
public void setGroupId(int groupId) { public void setGroupId(Integer groupId) {
this.groupId = groupId; this.groupId = groupId;
} }
@@ -51,29 +49,7 @@ public class Device {
this.deviceName = deviceName; this.deviceName = deviceName;
} }
@Override
public int hashCode() {
return Objects.hash(deviceId, deviceName, groupId);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Device other = (Device) obj;
return deviceId == other.deviceId
&& Objects.equals(deviceName, other.deviceName)
&& groupId == other.groupId;
}
@Override
public String toString() {
return "Device [deviceId=" + deviceId + ", groupId=" + groupId + ", deviceName=" + deviceName + "]";
}

View File

@@ -8,9 +8,9 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_co_by_device") @Table("v_co_by_device")
public class DeviceCO { public class DeviceCO {
int deviceId; private Integer deviceId;
float carbonMonoxide; private Float carbonMonoxide;
long timestamp; private Long timestamp;
public DeviceCO() {} public DeviceCO() {}
@@ -20,22 +20,22 @@ public class DeviceCO {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DeviceCO(int deviceId, float carbonMonoxide, long timestamp) { public DeviceCO(Integer deviceId, Float carbonMonoxide, Long timestamp) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.carbonMonoxide = carbonMonoxide; this.carbonMonoxide = carbonMonoxide;
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public float getCarbonMonoxide() { public Float getCarbonMonoxide() {
return carbonMonoxide; return carbonMonoxide;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -53,8 +53,8 @@ public class DeviceCO {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceCO other = (DeviceCO) obj; DeviceCO other = (DeviceCO) obj;
return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) return Objects.equals(carbonMonoxide, other.carbonMonoxide) && Objects.equals(deviceId, other.deviceId)
&& deviceId == other.deviceId && timestamp == other.timestamp; && Objects.equals(timestamp, other.timestamp);
} }
@Override @Override
@@ -62,4 +62,6 @@ public class DeviceCO {
return "DeviceCO [deviceId=" + deviceId + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp return "DeviceCO [deviceId=" + deviceId + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp
+ "]"; + "]";
} }
} }

View File

@@ -8,10 +8,10 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_gps_by_device") @Table("v_gps_by_device")
public class DeviceGPS { public class DeviceGPS {
int deviceId; private Integer deviceId;
float lat; private Float lat;
float lon; private Float lon;
long timestamp; private Long timestamp;
public DeviceGPS() {} public DeviceGPS() {}
@@ -22,26 +22,26 @@ public class DeviceGPS {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DeviceGPS(int deviceId, long lat, long lon) { public DeviceGPS(Integer deviceId, Float lat, Float lon) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.lat = lat; this.lat = lat;
this.lon = lon; this.lon = lon;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public float getLat() { public Float getLat() {
return lat; return lat;
} }
public float getLon() { public Float getLon() {
return lon; return lon;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -59,12 +59,14 @@ public class DeviceGPS {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceGPS other = (DeviceGPS) obj; DeviceGPS other = (DeviceGPS) obj;
return deviceId == other.deviceId && Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) return Objects.equals(deviceId, other.deviceId) && Objects.equals(lat, other.lat)
&& Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && timestamp == other.timestamp; && Objects.equals(lon, other.lon) && Objects.equals(timestamp, other.timestamp);
} }
@Override @Override
public String toString() { public String toString() {
return "DeviceGPS [deviceId=" + deviceId + ", lat=" + lat + ", lon=" + lon + ", timestamp=" + timestamp + "]"; return "DeviceGPS [deviceId=" + deviceId + ", lat=" + lat + ", lon=" + lon + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -7,44 +7,39 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_latest_values") @Table("v_latest_values")
public class DeviceLatestValuesView { public class DeviceLatestValuesView {
int deviceId; private Integer deviceId;
int sensorId; private Integer sensorId;
String sensorType; private String sensorType;
String unit; private String unit;
int sensorStatus; private Integer sensorStatus;
long sensorTimestamp; private Long sensorTimestamp;
float temperature; private Float temperature;
float humidity; private Float humidity;
float carbonMonoxide; private Float carbonMonoxide;
float lat; private Float lat;
float lon; private Float lon;
long airValuesTimestamp; private Long airValuesTimestamp;
public DeviceLatestValuesView() {} public DeviceLatestValuesView() {}
public DeviceLatestValuesView(Row row) { public DeviceLatestValuesView(Row row) {
this.deviceId = row.getInteger("deviceId") != null ? row.getInteger("deviceId") : -1; this.deviceId = row.getInteger("deviceId");
this.sensorId = row.getInteger("sensorId") != null ? row.getInteger("sensorId") : -1; this.sensorId = row.getInteger("sensorId");
this.sensorType = row.getString("sensorType") != null ? row.getString("sensorType") : "unknown"; this.sensorType = row.getString("sensorType");
this.unit = row.getString("unit") != null ? row.getString("unit") : "unknown"; this.unit = row.getString("unit");
this.sensorStatus = row.getInteger("sensorStatus") != null ? row.getInteger("sensorStatus") : 0; this.sensorStatus = row.getInteger("sensorStatus");
this.sensorTimestamp = DateParser.parseDate(row.getLocalDateTime("sensorTimestamp"));
this.sensorTimestamp = row.getLocalDateTime("sensorTimestamp") != null ? this.temperature = row.getFloat("temperature");
DateParser.parseDate(row.getLocalDateTime("sensorTimestamp")) : 0; this.humidity = row.getFloat("humidity");
this.carbonMonoxide = row.getFloat("carbonMonoxide");
this.temperature = row.getFloat("temperature") != null ? row.getFloat("temperature") : 0.0f; this.lat = row.getFloat("lat");
this.humidity = row.getFloat("humidity") != null ? row.getFloat("humidity") : 0.0f; this.lon = row.getFloat("lon");
this.carbonMonoxide = row.getFloat("carbonMonoxide") != null ? row.getFloat("carbonMonoxide") : 0.0f; this.airValuesTimestamp = DateParser.parseDate(row.getLocalDateTime("airValuesTimestamp"));
this.lat = row.getFloat("lat") != null ? row.getFloat("lat") : 0.0f;
this.lon = row.getFloat("lon") != null ? row.getFloat("lon") : 0.0f;
this.airValuesTimestamp = row.getLocalDateTime("airValuesTimestamp") != null ?
DateParser.parseDate(row.getLocalDateTime("airValuesTimestamp")) : 0;
} }
public DeviceLatestValuesView(int deviceId, int sensorId, String sensorType, String unit, int sensorStatus, public DeviceLatestValuesView(Integer deviceId, Integer sensorId, String sensorType, String unit, Integer sensorStatus,
long sensorTimestamp, float temperature, float humidity, float carbonMonoxide, float lat, float lon, Long sensorTimestamp, Float temperature, Float humidity, Float carbonMonoxide, Float lat, Float lon,
long airValuesTimestamp) { Long airValuesTimestamp) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.sensorId = sensorId; this.sensorId = sensorId;
@@ -60,11 +55,11 @@ public class DeviceLatestValuesView {
this.airValuesTimestamp = airValuesTimestamp; this.airValuesTimestamp = airValuesTimestamp;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
@@ -76,35 +71,35 @@ public class DeviceLatestValuesView {
return unit; return unit;
} }
public int getSensorStatus() { public Integer getSensorStatus() {
return sensorStatus; return sensorStatus;
} }
public long getSensorTimestamp() { public Long getSensorTimestamp() {
return sensorTimestamp; return sensorTimestamp;
} }
public float getTemperature() { public Float getTemperature() {
return temperature; return temperature;
} }
public float getHumidity() { public Float getHumidity() {
return humidity; return humidity;
} }
public float getCarbonMonoxide() { public Float getCarbonMonoxide() {
return carbonMonoxide; return carbonMonoxide;
} }
public float getLat() { public Float getLat() {
return lat; return lat;
} }
public float getLon() { public Float getLon() {
return lon; return lon;
} }
public long getAirValuesTimestamp() { public Long getAirValuesTimestamp() {
return airValuesTimestamp; return airValuesTimestamp;
} }
@@ -123,14 +118,13 @@ public class DeviceLatestValuesView {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceLatestValuesView other = (DeviceLatestValuesView) obj; DeviceLatestValuesView other = (DeviceLatestValuesView) obj;
return airValuesTimestamp == other.airValuesTimestamp return Objects.equals(airValuesTimestamp, other.airValuesTimestamp)
&& Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) && Objects.equals(carbonMonoxide, other.carbonMonoxide) && Objects.equals(deviceId, other.deviceId)
&& deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) && Objects.equals(humidity, other.humidity) && Objects.equals(lat, other.lat)
&& Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) && Objects.equals(lon, other.lon) && Objects.equals(sensorId, other.sensorId)
&& Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && sensorId == other.sensorId && Objects.equals(sensorStatus, other.sensorStatus)
&& sensorStatus == other.sensorStatus && sensorTimestamp == other.sensorTimestamp && Objects.equals(sensorTimestamp, other.sensorTimestamp)
&& Objects.equals(sensorType, other.sensorType) && Objects.equals(sensorType, other.sensorType) && Objects.equals(temperature, other.temperature)
&& Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature)
&& Objects.equals(unit, other.unit); && Objects.equals(unit, other.unit);
} }
@@ -141,6 +135,8 @@ public class DeviceLatestValuesView {
+ ", temperature=" + temperature + ", humidity=" + humidity + ", carbonMonoxide=" + carbonMonoxide + ", temperature=" + temperature + ", humidity=" + humidity + ", carbonMonoxide=" + carbonMonoxide
+ ", lat=" + lat + ", lon=" + lon + ", airValuesTimestamp=" + airValuesTimestamp + "]"; + ", lat=" + lat + ", lon=" + lon + ", airValuesTimestamp=" + airValuesTimestamp + "]";
} }
} }

View File

@@ -8,12 +8,12 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_pollution_map") @Table("v_pollution_map")
public class DevicePollutionMap { public class DevicePollutionMap {
int deviceId; private Integer deviceId;
String deviceName; private String deviceName;
float lat; private Float lat;
float lon; private Float lon;
float carbonMonoxide; private Float carbonMonoxide;
long timestamp; private Long timestamp;
public DevicePollutionMap() {} public DevicePollutionMap() {}
@@ -26,8 +26,8 @@ public class DevicePollutionMap {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DevicePollutionMap(int deviceId, String deviceName, float lat, float lon, float carbonMonoxide, public DevicePollutionMap(Integer deviceId, String deviceName, Float lat, Float lon, Float carbonMonoxide,
long timestamp) { Long timestamp) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.deviceName = deviceName; this.deviceName = deviceName;
@@ -37,7 +37,7 @@ public class DevicePollutionMap {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
@@ -45,19 +45,19 @@ public class DevicePollutionMap {
return deviceName; return deviceName;
} }
public float getLat() { public Float getLat() {
return lat; return lat;
} }
public float getLon() { public Float getLon() {
return lon; return lon;
} }
public float getCarbonMonoxide() { public Float getCarbonMonoxide() {
return carbonMonoxide; return carbonMonoxide;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -75,10 +75,9 @@ public class DevicePollutionMap {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DevicePollutionMap other = (DevicePollutionMap) obj; DevicePollutionMap other = (DevicePollutionMap) obj;
return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) return Objects.equals(carbonMonoxide, other.carbonMonoxide) && Objects.equals(deviceId, other.deviceId)
&& deviceId == other.deviceId && Objects.equals(deviceName, other.deviceName) && Objects.equals(deviceName, other.deviceName) && Objects.equals(lat, other.lat)
&& Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) && Objects.equals(lon, other.lon) && Objects.equals(timestamp, other.timestamp);
&& Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && timestamp == other.timestamp;
} }
@Override @Override
@@ -86,4 +85,6 @@ public class DevicePollutionMap {
return "DevicePollutionMap [deviceId=" + deviceId + ", deviceName=" + deviceName + ", lat=" + lat + ", lon=" return "DevicePollutionMap [deviceId=" + deviceId + ", deviceName=" + deviceName + ", lat=" + lat + ", lon="
+ lon + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp + "]"; + lon + ", carbonMonoxide=" + carbonMonoxide + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -8,11 +8,11 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_sensor_history_by_device") @Table("v_sensor_history_by_device")
public class DeviceSensorHistory { public class DeviceSensorHistory {
int deviceId; private Integer deviceId;
String deviceName; private String deviceName;
float value; private Float value;
String valueType; private String valueType;
long timestamp; private Long timestamp;
public DeviceSensorHistory() {} public DeviceSensorHistory() {}
@@ -24,7 +24,7 @@ public class DeviceSensorHistory {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DeviceSensorHistory(int deviceId, String deviceName, float value, String valueType, long timestamp) { public DeviceSensorHistory(Integer deviceId, String deviceName, Float value, String valueType, Long timestamp) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.deviceName = deviceName; this.deviceName = deviceName;
@@ -33,7 +33,7 @@ public class DeviceSensorHistory {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
@@ -41,7 +41,7 @@ public class DeviceSensorHistory {
return deviceName; return deviceName;
} }
public float getValue() { public Float getValue() {
return value; return value;
} }
@@ -49,7 +49,7 @@ public class DeviceSensorHistory {
return valueType; return valueType;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -67,8 +67,8 @@ public class DeviceSensorHistory {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceSensorHistory other = (DeviceSensorHistory) obj; DeviceSensorHistory other = (DeviceSensorHistory) obj;
return deviceId == other.deviceId && Objects.equals(deviceName, other.deviceName) return Objects.equals(deviceId, other.deviceId) && Objects.equals(deviceName, other.deviceName)
&& timestamp == other.timestamp && Float.floatToIntBits(value) == Float.floatToIntBits(other.value) && Objects.equals(timestamp, other.timestamp) && Objects.equals(value, other.value)
&& Objects.equals(valueType, other.valueType); && Objects.equals(valueType, other.valueType);
} }
@@ -77,4 +77,6 @@ public class DeviceSensorHistory {
return "DeviceSensorHistory [deviceId=" + deviceId + ", deviceName=" + deviceName + ", value=" + value return "DeviceSensorHistory [deviceId=" + deviceId + ", deviceName=" + deviceName + ", value=" + value
+ ", valueType=" + valueType + ", timestamp=" + timestamp + "]"; + ", valueType=" + valueType + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -8,17 +8,17 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_sensor_values") @Table("v_sensor_values")
public class DeviceSensorValue { public class DeviceSensorValue {
int sensorId; private Integer sensorId;
int deviceId; private Integer deviceId;
String sensorType; private String sensorType;
String unit; private String unit;
int sensorStatus; private Integer sensorStatus;
float temperature; private Float temperature;
float humidity; private Float humidity;
float carbonMonoxide; private Float carbonMonoxide;
float lat; private Float lat;
float lon; private Float lon;
long timestamp; private Long timestamp;
public DeviceSensorValue() {} public DeviceSensorValue() {}
@@ -36,8 +36,8 @@ public class DeviceSensorValue {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DeviceSensorValue(int sensorId, int deviceId, String sensorType, String unit, int sensorStatus, public DeviceSensorValue(Integer sensorId, Integer deviceId, String sensorType, String unit, Integer sensorStatus,
float temperature, float humidity, float carbonMonoxide, float lat, float lon, long timestamp) { Float temperature, Float humidity, Float carbonMonoxide, Float lat, Float lon, Long timestamp) {
super(); super();
this.sensorId = sensorId; this.sensorId = sensorId;
this.deviceId = deviceId; this.deviceId = deviceId;
@@ -52,11 +52,11 @@ public class DeviceSensorValue {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
@@ -68,31 +68,31 @@ public class DeviceSensorValue {
return unit; return unit;
} }
public int getSensorStatus() { public Integer getSensorStatus() {
return sensorStatus; return sensorStatus;
} }
public float getTemperature() { public Float getTemperature() {
return temperature; return temperature;
} }
public float getHumidity() { public Float getHumidity() {
return humidity; return humidity;
} }
public float getCarbonMonoxide() { public Float getCarbonMonoxide() {
return carbonMonoxide; return carbonMonoxide;
} }
public float getLat() { public Float getLat() {
return lat; return lat;
} }
public float getLon() { public Float getLon() {
return lon; return lon;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -111,13 +111,12 @@ public class DeviceSensorValue {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceSensorValue other = (DeviceSensorValue) obj; DeviceSensorValue other = (DeviceSensorValue) obj;
return Float.floatToIntBits(carbonMonoxide) == Float.floatToIntBits(other.carbonMonoxide) return Objects.equals(carbonMonoxide, other.carbonMonoxide) && Objects.equals(deviceId, other.deviceId)
&& deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) && Objects.equals(humidity, other.humidity) && Objects.equals(lat, other.lat)
&& Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) && Objects.equals(lon, other.lon) && Objects.equals(sensorId, other.sensorId)
&& Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && sensorId == other.sensorId && Objects.equals(sensorStatus, other.sensorStatus) && Objects.equals(sensorType, other.sensorType)
&& sensorStatus == other.sensorStatus && Objects.equals(sensorType, other.sensorType) && Objects.equals(temperature, other.temperature) && Objects.equals(timestamp, other.timestamp)
&& Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) && Objects.equals(unit, other.unit);
&& timestamp == other.timestamp && Objects.equals(unit, other.unit);
} }
@Override @Override
@@ -127,4 +126,6 @@ public class DeviceSensorValue {
+ humidity + ", carbonMonoxide=" + carbonMonoxide + ", lat=" + lat + ", lon=" + lon + ", timestamp=" + humidity + ", carbonMonoxide=" + carbonMonoxide + ", lat=" + lat + ", lon=" + lon + ", timestamp="
+ timestamp + "]"; + timestamp + "]";
} }
} }

View File

@@ -8,10 +8,10 @@ import net.miarma.contaminus.util.DateParser;
@Table("v_weather_by_device") @Table("v_weather_by_device")
public class DeviceWeather { public class DeviceWeather {
int deviceId; private Integer deviceId;
float temperature; private Float temperature;
float humidity; private Float humidity;
long timestamp; private Long timestamp;
public DeviceWeather() {} public DeviceWeather() {}
@@ -22,7 +22,7 @@ public class DeviceWeather {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public DeviceWeather(int deviceId, float temperature, float humidity, long timestamp) { public DeviceWeather(Integer deviceId, Float temperature, Float humidity, Long timestamp) {
super(); super();
this.deviceId = deviceId; this.deviceId = deviceId;
this.temperature = temperature; this.temperature = temperature;
@@ -30,19 +30,19 @@ public class DeviceWeather {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public float getTemperature() { public Float getTemperature() {
return temperature; return temperature;
} }
public float getHumidity() { public Float getHumidity() {
return humidity; return humidity;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
@@ -60,9 +60,8 @@ public class DeviceWeather {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
DeviceWeather other = (DeviceWeather) obj; DeviceWeather other = (DeviceWeather) obj;
return deviceId == other.deviceId && Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) return Objects.equals(deviceId, other.deviceId) && Objects.equals(humidity, other.humidity)
&& Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) && Objects.equals(temperature, other.temperature) && Objects.equals(timestamp, other.timestamp);
&& timestamp == other.timestamp;
} }
@Override @Override
@@ -70,4 +69,6 @@ public class DeviceWeather {
return "DeviceWeather [deviceId=" + deviceId + ", temperature=" + temperature + ", humidity=" + humidity return "DeviceWeather [deviceId=" + deviceId + ", temperature=" + temperature + ", humidity=" + humidity
+ ", timestamp=" + timestamp + "]"; + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -9,11 +9,11 @@ import net.miarma.contaminus.util.DateParser;
@Table("gps_values") @Table("gps_values")
public class GpsValue { public class GpsValue {
private int valueId; private Integer valueId;
private int sensorId; private Integer sensorId;
private float lat; private Float lat;
private float lon; private Float lon;
private long timestamp; private Long timestamp;
public GpsValue() {} public GpsValue() {}
@@ -25,7 +25,7 @@ public class GpsValue {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public GpsValue(int valueId, int sensorId, float lat, float lon, long timestamp) { public GpsValue(Integer valueId, Integer sensorId, Float lat, Float lon, Long timestamp) {
super(); super();
this.valueId = valueId; this.valueId = valueId;
this.sensorId = sensorId; this.sensorId = sensorId;
@@ -34,43 +34,43 @@ public class GpsValue {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getValueId() { public Integer getValueId() {
return valueId; return valueId;
} }
public void setValueId(int valueId) { public void setValueId(Integer valueId) {
this.valueId = valueId; this.valueId = valueId;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
public void setSensorId(int sensorId) { public void setSensorId(Integer sensorId) {
this.sensorId = sensorId; this.sensorId = sensorId;
} }
public float getLat() { public Float getLat() {
return lat; return lat;
} }
public void setLat(float lat) { public void setLat(Float lat) {
this.lat = lat; this.lat = lat;
} }
public float getLon() { public Float getLon() {
return lon; return lon;
} }
public void setLon(float lon) { public void setLon(Float lon) {
this.lon = lon; this.lon = lon;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
public void setTimestamp(long timestamp) { public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
@@ -88,9 +88,9 @@ public class GpsValue {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
GpsValue other = (GpsValue) obj; GpsValue other = (GpsValue) obj;
return Float.floatToIntBits(lat) == Float.floatToIntBits(other.lat) return Objects.equals(lat, other.lat) && Objects.equals(lon, other.lon)
&& Float.floatToIntBits(lon) == Float.floatToIntBits(other.lon) && Objects.equals(sensorId, other.sensorId) && Objects.equals(timestamp, other.timestamp)
&& sensorId == other.sensorId && timestamp == other.timestamp && valueId == other.valueId; && Objects.equals(valueId, other.valueId);
} }
@Override @Override

View File

@@ -8,7 +8,7 @@ import net.miarma.contaminus.common.Table;
@Table("groups") @Table("groups")
public class Group { public class Group {
private int groupId; private Integer groupId;
private String groupName; private String groupName;
public Group() {} public Group() {}
@@ -18,17 +18,17 @@ public class Group {
this.groupName = row.getString("groupName"); this.groupName = row.getString("groupName");
} }
public Group(int groupId, String groupName) { public Group(Integer groupId, String groupName) {
super(); super();
this.groupId = groupId; this.groupId = groupId;
this.groupName = groupName; this.groupName = groupName;
} }
public int getGroupId() { public Integer getGroupId() {
return groupId; return groupId;
} }
public void setGroupId(int groupId) { public void setGroupId(Integer groupId) {
this.groupId = groupId; this.groupId = groupId;
} }
@@ -54,8 +54,7 @@ public class Group {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
Group other = (Group) obj; Group other = (Group) obj;
return groupId == other.groupId return Objects.equals(groupId, other.groupId) && Objects.equals(groupName, other.groupName);
&& Objects.equals(groupName, other.groupName);
} }
@Override @Override
@@ -63,5 +62,5 @@ public class Group {
return "Group [groupId=" + groupId + ", groupName=" + groupName + "]"; return "Group [groupId=" + groupId + ", groupName=" + groupName + "]";
} }
} }

View File

@@ -9,12 +9,12 @@ import net.miarma.contaminus.util.DateParser;
@Table("sensors") @Table("sensors")
public class Sensor { public class Sensor {
private int sensorId; private Integer sensorId;
private int deviceId; private Integer deviceId;
private String sensorType; private String sensorType;
private String unit; private String unit;
private int status; private Integer status;
private long timestamp; private Long timestamp;
public Sensor() {} public Sensor() {}
@@ -27,7 +27,7 @@ public class Sensor {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public Sensor(int sensorId, int deviceId, String sensorType, String unit, int status, long timestamp) { public Sensor(Integer sensorId, Integer deviceId, String sensorType, String unit, Integer status, Long timestamp) {
super(); super();
this.sensorId = sensorId; this.sensorId = sensorId;
this.deviceId = deviceId; this.deviceId = deviceId;
@@ -37,19 +37,19 @@ public class Sensor {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
public void setSensorId(int sensorId) { public void setSensorId(Integer sensorId) {
this.sensorId = sensorId; this.sensorId = sensorId;
} }
public int getDeviceId() { public Integer getDeviceId() {
return deviceId; return deviceId;
} }
public void setDeviceId(int deviceId) { public void setDeviceId(Integer deviceId) {
this.deviceId = deviceId; this.deviceId = deviceId;
} }
@@ -69,19 +69,19 @@ public class Sensor {
this.unit = unit; this.unit = unit;
} }
public int getStatus() { public Integer getStatus() {
return status; return status;
} }
public void setStatus(int status) { public void setStatus(Integer status) {
this.status = status; this.status = status;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
public void setTimestamp(long timestamp) { public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
@@ -99,8 +99,9 @@ public class Sensor {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
Sensor other = (Sensor) obj; Sensor other = (Sensor) obj;
return deviceId == other.deviceId && sensorId == other.sensorId && Objects.equals(sensorType, other.sensorType) return Objects.equals(deviceId, other.deviceId) && Objects.equals(sensorId, other.sensorId)
&& status == other.status && timestamp == other.timestamp && Objects.equals(unit, other.unit); && Objects.equals(sensorType, other.sensorType) && Objects.equals(status, other.status)
&& Objects.equals(timestamp, other.timestamp) && Objects.equals(unit, other.unit);
} }
@Override @Override
@@ -109,5 +110,5 @@ public class Sensor {
+ unit + ", status=" + status + ", timestamp=" + timestamp + "]"; + unit + ", status=" + status + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -9,11 +9,11 @@ import net.miarma.contaminus.util.DateParser;
@Table("weather_values") @Table("weather_values")
public class WeatherValue { public class WeatherValue {
private int valueId; private Integer valueId;
private int sensorId; private Integer sensorId;
private float temperature; private Float temperature;
private float humidity; private Float humidity;
private long timestamp; private Long timestamp;
public WeatherValue() {} public WeatherValue() {}
@@ -25,7 +25,7 @@ public class WeatherValue {
this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp")); this.timestamp = DateParser.parseDate(row.getLocalDateTime("timestamp"));
} }
public WeatherValue(int valueId, int sensorId, float temperature, float humidity, long timestamp) { public WeatherValue(Integer valueId, Integer sensorId, Float temperature, Float humidity, Long timestamp) {
super(); super();
this.valueId = valueId; this.valueId = valueId;
this.sensorId = sensorId; this.sensorId = sensorId;
@@ -34,43 +34,43 @@ public class WeatherValue {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
public int getValueId() { public Integer getValueId() {
return valueId; return valueId;
} }
public void setValueId(int valueId) { public void setValueId(Integer valueId) {
this.valueId = valueId; this.valueId = valueId;
} }
public int getSensorId() { public Integer getSensorId() {
return sensorId; return sensorId;
} }
public void setSensorId(int sensorId) { public void setSensorId(Integer sensorId) {
this.sensorId = sensorId; this.sensorId = sensorId;
} }
public float getTemperature() { public Float getTemperature() {
return temperature; return temperature;
} }
public void setTemperature(float temperature) { public void setTemperature(Float temperature) {
this.temperature = temperature; this.temperature = temperature;
} }
public float getHumidity() { public Float getHumidity() {
return humidity; return humidity;
} }
public void setHumidity(float humidity) { public void setHumidity(Float humidity) {
this.humidity = humidity; this.humidity = humidity;
} }
public long getTimestamp() { public Long getTimestamp() {
return timestamp; return timestamp;
} }
public void setTimestamp(long timestamp) { public void setTimestamp(Long timestamp) {
this.timestamp = timestamp; this.timestamp = timestamp;
} }
@@ -88,9 +88,9 @@ public class WeatherValue {
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
return false; return false;
WeatherValue other = (WeatherValue) obj; WeatherValue other = (WeatherValue) obj;
return Float.floatToIntBits(humidity) == Float.floatToIntBits(other.humidity) && sensorId == other.sensorId return Objects.equals(humidity, other.humidity) && Objects.equals(sensorId, other.sensorId)
&& Float.floatToIntBits(temperature) == Float.floatToIntBits(other.temperature) && Objects.equals(temperature, other.temperature) && Objects.equals(timestamp, other.timestamp)
&& timestamp == other.timestamp && valueId == other.valueId; && Objects.equals(valueId, other.valueId);
} }
@Override @Override
@@ -99,6 +99,6 @@ public class WeatherValue {
+ ", humidity=" + humidity + ", timestamp=" + timestamp + "]"; + ", humidity=" + humidity + ", timestamp=" + timestamp + "]";
} }
} }

View File

@@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.vertx.core.AbstractVerticle; import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise; import io.vertx.core.Promise;
@@ -27,7 +28,7 @@ public class DataLayerAPIVerticle extends AbstractVerticle {
private JDBCPool pool; private JDBCPool pool;
private DatabaseManager dbManager; private DatabaseManager dbManager;
private ConfigManager configManager; private ConfigManager configManager;
private Gson gson = new Gson(); private final Gson gson = new GsonBuilder().serializeNulls().create();
public DataLayerAPIVerticle(JDBCPool pool) { public DataLayerAPIVerticle(JDBCPool pool) {
this.pool = pool; this.pool = pool;

View File

@@ -4,8 +4,10 @@ import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Stream;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import io.vertx.core.AbstractVerticle; import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise; import io.vertx.core.Promise;
@@ -19,18 +21,18 @@ import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.ext.web.handler.CorsHandler; import io.vertx.ext.web.handler.CorsHandler;
import net.miarma.contaminus.common.ConfigManager; import net.miarma.contaminus.common.ConfigManager;
import net.miarma.contaminus.common.Constants; import net.miarma.contaminus.common.Constants;
import net.miarma.contaminus.database.entities.Actuator;
import net.miarma.contaminus.database.entities.Device; import net.miarma.contaminus.database.entities.Device;
import net.miarma.contaminus.database.entities.DeviceLatestValuesView; import net.miarma.contaminus.database.entities.DeviceLatestValuesView;
import net.miarma.contaminus.database.entities.DevicePollutionMap; import net.miarma.contaminus.database.entities.DevicePollutionMap;
import net.miarma.contaminus.database.entities.DeviceSensorHistory; import net.miarma.contaminus.database.entities.DeviceSensorHistory;
import net.miarma.contaminus.database.entities.DeviceSensorValue; import net.miarma.contaminus.database.entities.DeviceSensorValue;
import net.miarma.contaminus.database.entities.Actuator;
import net.miarma.contaminus.database.entities.Sensor; import net.miarma.contaminus.database.entities.Sensor;
import net.miarma.contaminus.util.RestClientUtil; import net.miarma.contaminus.util.RestClientUtil;
public class LogicLayerAPIVerticle extends AbstractVerticle { public class LogicLayerAPIVerticle extends AbstractVerticle {
private ConfigManager configManager; private ConfigManager configManager;
private final Gson gson = new Gson(); private final Gson gson = new GsonBuilder().serializeNulls().create();
private RestClientUtil restClient; private RestClientUtil restClient;
public LogicLayerAPIVerticle() { public LogicLayerAPIVerticle() {
@@ -81,7 +83,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
Promise<Device[]> resultList = Promise.promise(); Promise<Device[]> resultList = Promise.promise();
resultList.future().onComplete(complete -> { resultList.future().onComplete(complete -> {
if(complete.succeeded()) { if(complete.succeeded()) {
List<Device> aux = Arrays.asList(complete.result()).stream() List<Device> aux = Stream.of(complete.result())
.filter(d -> d.getGroupId() == groupId) .filter(d -> d.getGroupId() == groupId)
.toList(); .toList();
context.response() context.response()
@@ -93,7 +95,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_GROUP_DEVICES, Device[].class, resultList); Constants.GET_DEVICES, Device[].class, resultList);
} }
private void getDeviceSensors(RoutingContext context) { private void getDeviceSensors(RoutingContext context) {
@@ -131,17 +133,16 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_DEVICES, Actuator[].class, resultList); Constants.GET_ACTUATORS, Actuator[].class, resultList);
} }
private void getDeviceLatestValues(RoutingContext context) { private void getDeviceLatestValues(RoutingContext context) {
Integer deviceId = Integer.parseInt(context.request().getParam("deviceId")); Integer deviceId = Integer.parseInt(context.request().getParam("deviceId"));
Promise<DeviceLatestValuesView[]> resultList = Promise.promise(); Promise<DeviceLatestValuesView[]> resultList = Promise.promise();
resultList.future().onComplete(complete -> { resultList.future().onComplete(complete -> {
if (complete.succeeded()) { if (complete.succeeded()) {
List<DeviceLatestValuesView> aux = Arrays.asList(complete.result()).stream() List<DeviceLatestValuesView> aux = Stream.of(complete.result())
.filter(d -> d.getDeviceId() == deviceId) .filter(d -> d.getDeviceId() == deviceId)
.toList(); .toList();
@@ -154,7 +155,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_DEVICE_LATEST_VALUES, DeviceLatestValuesView[].class, resultList); Constants.GET_LATEST_VALUES_VIEW, DeviceLatestValuesView[].class, resultList);
} }
private void getDevicePollutionMap(RoutingContext context) { private void getDevicePollutionMap(RoutingContext context) {
@@ -177,7 +178,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_DEVICE_POLLUTION_MAP, DevicePollutionMap[].class, resultList); Constants.GET_POLLUTION_MAP_VIEW, DevicePollutionMap[].class, resultList);
} }
private void getDeviceHistory(RoutingContext context) { private void getDeviceHistory(RoutingContext context) {
@@ -200,7 +201,7 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_DEVICE_HISTORY, DeviceSensorHistory[].class, resultList); Constants.GET_SENSOR_HISTORY_BY_DEVICE_VIEW, DeviceSensorHistory[].class, resultList);
} }
private void getSensorValues(RoutingContext context) { private void getSensorValues(RoutingContext context) {
@@ -223,6 +224,6 @@ public class LogicLayerAPIVerticle extends AbstractVerticle {
}); });
this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(), this.restClient.getRequest(configManager.getDataApiPort(), "http://" + configManager.getHost(),
Constants.GET_SENSOR_VALUES, DeviceSensorValue[].class, resultList); Constants.GET_SENSOR_VALUES_VIEW, DeviceSensorValue[].class, resultList);
} }
} }

View File

@@ -33,6 +33,8 @@ public class RestClientUtil {
public <T> void getRequest(Integer port, String host, String resource, Class<T> classType, Promise<T> promise) { public <T> void getRequest(Integer port, String host, String resource, Class<T> classType, Promise<T> promise) {
client.getAbs(host + ":" + port + resource).send(elem -> { client.getAbs(host + ":" + port + resource).send(elem -> {
if (elem.succeeded()) { if (elem.succeeded()) {
System.out.println(host + ":" + port + resource);
System.out.println(elem.result().bodyAsString());
promise.complete(gson.fromJson(elem.result().bodyAsString(), classType)); promise.complete(gson.fromJson(elem.result().bodyAsString(), classType));
} else { } else {
promise.fail(elem.cause()); promise.fail(elem.cause());