|
@@ -142,7 +142,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
private static final Function<Row, Sensor> ROW_TO_SENSOR = (row) -> Sensor.of(
|
|
private static final Function<Row, Sensor> ROW_TO_SENSOR = (row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type"),
|
|
|
|
|
|
|
+ row.getString("type"),
|
|
|
row.getInteger("io_id"),
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(
|
|
Phenomenon.of(
|
|
|
row.getInteger("phenomenon_id"),
|
|
row.getInteger("phenomenon_id"),
|
|
@@ -153,7 +153,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<Sensor> findSensorById(long sensorId) {
|
|
public Future<Sensor> findSensorById(long sensorId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type, s.io_id, s.description, p.id AS phenomenon_id, p.name AS phenomenon_name, p.uom, p.uom_link " +
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.type, s.io_id, s.description, p.id AS phenomenon_id, p.name AS phenomenon_name, p.uom, p.uom_link " +
|
|
|
"FROM maplog.sensor AS s " +
|
|
"FROM maplog.sensor AS s " +
|
|
|
"JOIN maplog.phenomenon p on p.id = s.phenomenon_id " +
|
|
"JOIN maplog.phenomenon p on p.id = s.phenomenon_id " +
|
|
|
"WHERE s.sensor_id = $1")
|
|
"WHERE s.sensor_id = $1")
|
|
@@ -167,7 +167,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
private static final Function<Row, Sensor> ROW_TO_BASIC_SENSOR = (row) -> Sensor.of(
|
|
private static final Function<Row, Sensor> ROW_TO_BASIC_SENSOR = (row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type"),
|
|
|
|
|
|
|
+ row.getString("type"),
|
|
|
row.getInteger("io_id"),
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
|
row.getString("description")
|
|
row.getString("description")
|
|
@@ -175,7 +175,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<Sensor> findSensorByIOAndUnitId(int ioID, long unitId) {
|
|
public Future<Sensor> findSensorByIOAndUnitId(int ioID, long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type, s.io_id, s.phenomenon_id, s.description " +
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.type, s.io_id, s.phenomenon_id, s.description " +
|
|
|
"FROM maplog.sensor AS s " +
|
|
"FROM maplog.sensor AS s " +
|
|
|
"JOIN maplog.unit_to_sensor uts ON s.sensor_id = uts.sensor_id " +
|
|
"JOIN maplog.unit_to_sensor uts ON s.sensor_id = uts.sensor_id " +
|
|
|
"WHERE s.io_id = $1 AND uts.unit_id = $2")
|
|
"WHERE s.io_id = $1 AND uts.unit_id = $2")
|
|
@@ -188,13 +188,13 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<List<Sensor>> allSensors() {
|
|
public Future<List<Sensor>> allSensors() {
|
|
|
- return client.query("SELECT sensor_id, name, sensor_type, io_id, phenomenon_id, description FROM maplog.sensor ORDER BY sensor_id")
|
|
|
|
|
|
|
+ return client.query("SELECT sensor_id, name, type, io_id, phenomenon_id, description FROM maplog.sensor ORDER BY sensor_id")
|
|
|
.execute()
|
|
.execute()
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type"),
|
|
|
|
|
|
|
+ row.getString("type"),
|
|
|
row.getInteger("io_id"),
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
|
row.getString("description")
|
|
row.getString("description")
|
|
@@ -204,7 +204,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByUnitId(long unitId) {
|
|
public Future<List<Sensor>> findSensorsByUnitId(long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type " +
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.type " +
|
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
|
"WHERE UTS.unit_id = $1 ORDER BY s.sensor_id")
|
|
"WHERE UTS.unit_id = $1 ORDER BY s.sensor_id")
|
|
@@ -213,27 +213,27 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.map((row) -> Sensor.of(
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type")
|
|
|
|
|
|
|
+ row.getString("type")
|
|
|
)).collect(Collectors.toList())
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByPhenomenonId(long phenomenonId) {
|
|
public Future<List<Sensor>> findSensorsByPhenomenonId(long phenomenonId) {
|
|
|
- return client.preparedQuery("SELECT sensor_id, name, sensor_type FROM maplog.sensor WHERE phenomenon_id = $1 ORDER BY sensor_id")
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT sensor_id, name, type FROM maplog.sensor WHERE phenomenon_id = $1 ORDER BY sensor_id")
|
|
|
.execute(Tuple.of(phenomenonId))
|
|
.execute(Tuple.of(phenomenonId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type")
|
|
|
|
|
|
|
+ row.getString("type")
|
|
|
)).collect(Collectors.toList())
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByCampaignIdAndUnitId(long campaignId, long unitId) {
|
|
public Future<List<Sensor>> findSensorsByCampaignIdAndUnitId(long campaignId, long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type " +
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.type " +
|
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
|
"JOIN maplog.unit_to_campaign utc ON utc.unit_id = uts.unit_id " +
|
|
"JOIN maplog.unit_to_campaign utc ON utc.unit_id = uts.unit_id " +
|
|
@@ -243,14 +243,14 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.map((row) -> Sensor.of(
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
row.getLong("sensor_id"),
|
|
|
row.getString("name"),
|
|
row.getString("name"),
|
|
|
- row.getString("sensor_type")
|
|
|
|
|
|
|
+ row.getString("type")
|
|
|
)).collect(Collectors.toList())
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Future<Sensor> findSensorByCampaignIdAndUnitId(long campaignId, long unitId, long sensorId) {
|
|
public Future<Sensor> findSensorByCampaignIdAndUnitId(long campaignId, long unitId, long sensorId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type, s.io_id, s.description, p.id AS phenomenon_id, p.name AS phenomenon_name, p.uom, p.uom_link " +
|
|
|
|
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.type, s.io_id, s.description, p.id AS phenomenon_id, p.name AS phenomenon_name, p.uom, p.uom_link " +
|
|
|
"FROM maplog.sensor AS s " +
|
|
"FROM maplog.sensor AS s " +
|
|
|
"JOIN maplog.phenomenon AS p ON p.id = s.phenomenon_id " +
|
|
"JOIN maplog.phenomenon AS p ON p.id = s.phenomenon_id " +
|
|
|
"JOIN maplog.unit_to_sensor AS uts ON s.sensor_id = uts.sensor_id " +
|
|
"JOIN maplog.unit_to_sensor AS uts ON s.sensor_id = uts.sensor_id " +
|