|
|
@@ -68,7 +68,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
@Override
|
|
|
public Future<Integer> saveTelemetry(UnitTelemetry data) {
|
|
|
return client.preparedQuery("INSERT INTO maplog.obs_telemetry(unit_id, time_stamp, the_geom, speed, observed_values) " +
|
|
|
- "VALUES ($1, $2, ST_SetSRID(ST_MakePoint($3, $4, $5, $6), 4326), $7, $8::jsonb) RETURNING (obs_id)")
|
|
|
+ "VALUES ($1, $2, ST_SetSRID(ST_MakePoint($3, $4, $5, $6), 4326), $7, $8::jsonb) RETURNING (id)")
|
|
|
.execute(Tuple.of(
|
|
|
data.getUnitId(),
|
|
|
data.getTimestamp(),
|
|
|
@@ -103,7 +103,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
@Override
|
|
|
public Future<Boolean> createSensor(Sensor sensor, long unitId) {
|
|
|
return client.preparedQuery("WITH rows AS " +
|
|
|
- "(INSERT INTO maplog.sensor(sensor_id, io_id, sensor_name, phenomenon_id) VALUES ($1, $2, $3, $4) RETURNING sensor_id) " +
|
|
|
+ "(INSERT INTO maplog.sensor(sensor_id, io_id, name, phenomenon_id) VALUES ($1, $2, $3, $4) RETURNING sensor_id) " +
|
|
|
"INSERT INTO maplog.unit_to_sensor(sensor_id, unit_id) SELECT sensor_id, $5 FROM rows RETURNING sensor_id")
|
|
|
.execute(Tuple.of(sensor.getSensorId(), sensor.getIoID(), sensor.getName(), 1, unitId))
|
|
|
.map(r -> r.iterator().next().getInteger(0) > 0);
|
|
|
@@ -141,7 +141,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
private static final Function<Row, Sensor> ROW_TO_SENSOR = (row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type"),
|
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(
|
|
|
@@ -153,7 +153,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<Sensor> findSensorById(long sensorId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.sensor_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.sensor_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 " +
|
|
|
"JOIN maplog.phenomenon p on p.id = s.phenomenon_id " +
|
|
|
"WHERE s.sensor_id = $1")
|
|
|
@@ -166,7 +166,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
private static final Function<Row, Sensor> ROW_TO_BASIC_SENSOR = (row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type"),
|
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
|
@@ -175,7 +175,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<Sensor> findSensorByIOAndUnitId(int ioID, long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.sensor_name, s.sensor_type, s.io_id, s.phenomenon_id, s.description " +
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type, s.io_id, s.phenomenon_id, s.description " +
|
|
|
"FROM maplog.sensor AS s " +
|
|
|
"JOIN maplog.unit_to_sensor uts ON s.sensor_id = uts.sensor_id " +
|
|
|
"WHERE s.io_id = $1 AND uts.unit_id = $2")
|
|
|
@@ -188,12 +188,12 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Sensor>> allSensors() {
|
|
|
- return client.query("SELECT sensor_id, sensor_name, sensor_type, io_id, phenomenon_id, description FROM maplog.sensor ORDER BY sensor_id")
|
|
|
+ return client.query("SELECT sensor_id, name, sensor_type, io_id, phenomenon_id, description FROM maplog.sensor ORDER BY sensor_id")
|
|
|
.execute()
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type"),
|
|
|
row.getInteger("io_id"),
|
|
|
Phenomenon.of(row.getLong("phenomenon_id"), null),
|
|
|
@@ -204,7 +204,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByUnitId(long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.sensor_name, s.sensor_type " +
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type " +
|
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
|
"WHERE UTS.unit_id = $1 ORDER BY s.sensor_id")
|
|
|
@@ -212,7 +212,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type")
|
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
|
@@ -220,12 +220,12 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByPhenomenonId(long phenomenonId) {
|
|
|
- return client.preparedQuery("SELECT sensor_id, sensor_name, sensor_type FROM maplog.sensor WHERE phenomenon_id = $1 ORDER BY sensor_id")
|
|
|
+ return client.preparedQuery("SELECT sensor_id, name, sensor_type FROM maplog.sensor WHERE phenomenon_id = $1 ORDER BY sensor_id")
|
|
|
.execute(Tuple.of(phenomenonId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type")
|
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
|
@@ -233,16 +233,16 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Sensor>> findSensorsByCampaignIdAndUnitId(long campaignId, long unitId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.sensor_name, s.sensor_type " +
|
|
|
+ return client.preparedQuery("SELECT s.sensor_id, s.name, s.sensor_type " +
|
|
|
"FROM maplog.unit_to_sensor AS uts " +
|
|
|
"JOIN maplog.sensor s on s.sensor_id = uts.sensor_id " +
|
|
|
"JOIN maplog.unit_to_campaign utc ON utc.unit_id = uts.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND uts.unit_id = $2 ORDER BY s.sensor_id")
|
|
|
+ "WHERE utc.campaign_id = $1 AND uts.unit_id = $2 ORDER BY s.sensor_id")
|
|
|
.execute(Tuple.of(campaignId, unitId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Sensor.of(
|
|
|
row.getLong("sensor_id"),
|
|
|
- row.getString("sensor_name"),
|
|
|
+ row.getString("name"),
|
|
|
row.getString("sensor_type")
|
|
|
)).collect(Collectors.toList())
|
|
|
);
|
|
|
@@ -250,12 +250,12 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<Sensor> findSensorByCampaignIdAndUnitId(long campaignId, long unitId, long sensorId) {
|
|
|
- return client.preparedQuery("SELECT s.sensor_id, s.sensor_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.sensor_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 " +
|
|
|
"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_campaign AS utc ON utc.unit_id = uts.unit_id " +
|
|
|
- "WHERE s.sensor_id = $3 AND uts.unit_id = $2 AND utc.camp_id = $1")
|
|
|
+ "WHERE s.sensor_id = $3 AND uts.unit_id = $2 AND utc.campaign_id = $1")
|
|
|
.execute(Tuple.of(campaignId, unitId, sensorId))
|
|
|
.map(RowSet::iterator)
|
|
|
.map(iterator -> iterator.hasNext() ? ROW_TO_SENSOR.apply(iterator.next()) : null)
|
|
|
@@ -294,14 +294,14 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Campaign>> findCampaignsByUnitId(long unitId, ZoneId zone) {
|
|
|
- return client.preparedQuery("SELECT c.campaign_id, c.description, utc.from_time, utc.to_time " +
|
|
|
+ return client.preparedQuery("SELECT c.id, c.description, utc.from_time, utc.to_time " +
|
|
|
"FROM maplog.unit_to_campaign AS utc " +
|
|
|
- "JOIN maplog.campaign AS c on c.campaign_id = utc.camp_id " +
|
|
|
- "WHERE utc.unit_id = $1 ORDER BY c.campaign_id")
|
|
|
+ "JOIN maplog.campaign AS c on c.id = utc.campaign_id " +
|
|
|
+ "WHERE utc.unit_id = $1 ORDER BY c.id")
|
|
|
.execute(Tuple.of(unitId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Campaign.of(
|
|
|
- row.getLong("campaign_id"),
|
|
|
+ row.getLong("id"),
|
|
|
row.getString("description"),
|
|
|
row.getOffsetDateTime("from_time"),
|
|
|
row.getOffsetDateTime("to_time")
|
|
|
@@ -475,16 +475,16 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<CampaignUnit>> findUnitsByCampaignId(long campaignId) {
|
|
|
- return client.preparedQuery("SELECT u.unit_id, utc.camp_id, u.name, u.imei, u.unit_type_id, u.description, utc.from_time, utc.to_time " +
|
|
|
+ return client.preparedQuery("SELECT u.unit_id, utc.campaign_id, u.name, u.imei, u.unit_type_id, u.description, utc.from_time, utc.to_time " +
|
|
|
"FROM maplog.unit_to_campaign AS utc " +
|
|
|
- "JOIN maplog.campaign c on c.campaign_id = utc.camp_id " +
|
|
|
+ "JOIN maplog.campaign c on c.id = utc.campaign_id " +
|
|
|
"JOIN maplog.unit u on u.unit_id = utc.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 ORDER BY u.unit_id")
|
|
|
+ "WHERE utc.campaign_id = $1 ORDER BY u.unit_id")
|
|
|
.execute(Tuple.of(campaignId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> CampaignUnit.of(
|
|
|
row.getLong("unit_id"),
|
|
|
- row.getLong("camp_id"),
|
|
|
+ row.getLong("campaign_id"),
|
|
|
row.getString("name"),
|
|
|
row.getString("description"),
|
|
|
row.getOffsetDateTime("from_time"),
|
|
|
@@ -496,7 +496,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
private static final Function<Row, CampaignUnit> ROW_TO_CAMPAIGN_UNIT = (row) -> CampaignUnit.of(
|
|
|
row.getLong("unit_id"),
|
|
|
- row.getLong("camp_id"),
|
|
|
+ row.getLong("campaign_id"),
|
|
|
row.getString("name"),
|
|
|
row.getString("unit_type_id"),
|
|
|
row.getString("imei"),
|
|
|
@@ -507,10 +507,10 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<CampaignUnit> findUnitByIdAndCampaignId(long unitId, long campaignId) {
|
|
|
- return client.preparedQuery("SELECT u.unit_id, utc.camp_id, u.name, u.imei, u.unit_type_id, u.description, utc.from_time, utc.to_time " +
|
|
|
+ return client.preparedQuery("SELECT u.unit_id, utc.campaign_id, u.name, u.imei, u.unit_type_id, u.description, utc.from_time, utc.to_time " +
|
|
|
"FROM maplog.unit AS u " +
|
|
|
"JOIN maplog.unit_to_campaign utc on u.unit_id = utc.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND utc.unit_id = $2")
|
|
|
+ "WHERE utc.campaign_id = $1 AND utc.unit_id = $2")
|
|
|
.execute(Tuple.of(campaignId, unitId))
|
|
|
.map(RowSet::iterator)
|
|
|
.map(iterator -> iterator.hasNext() ? ROW_TO_CAMPAIGN_UNIT.apply(iterator.next()) : null)
|
|
|
@@ -568,11 +568,11 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Campaign>> allCampaigns() {
|
|
|
- return client.query("SELECT campaign_id, description, from_time, to_time FROM maplog.campaign ORDER BY campaign_id")
|
|
|
+ return client.query("SELECT id, description, from_time, to_time FROM maplog.campaign ORDER BY id")
|
|
|
.execute()
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map((row) -> Campaign.of(
|
|
|
- row.getLong("campaign_id"),
|
|
|
+ row.getLong("id"),
|
|
|
row.getString("description"),
|
|
|
row.getOffsetDateTime("from_time"),
|
|
|
row.getOffsetDateTime("to_time")
|
|
|
@@ -582,7 +582,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
}
|
|
|
|
|
|
private static final Function<Row, Campaign> ROW_TO_CAMPAIGN = (row) -> Campaign.of(
|
|
|
- row.getLong("campaign_id"),
|
|
|
+ row.getLong("id"),
|
|
|
row.getString("description"),
|
|
|
row.getOffsetDateTime("from_time"),
|
|
|
row.getOffsetDateTime("to_time")
|
|
|
@@ -590,7 +590,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<Campaign> findCampaignById(long campaignId) {
|
|
|
- return client.preparedQuery("SELECT campaign_id, description, from_time, to_time FROM maplog.campaign WHERE campaign_id = $1")
|
|
|
+ return client.preparedQuery("SELECT id, description, from_time, to_time FROM maplog.campaign WHERE id = $1")
|
|
|
.execute(Tuple.of(campaignId))
|
|
|
.map(RowSet::iterator)
|
|
|
.map(it -> it.hasNext() ? ROW_TO_CAMPAIGN.apply(it.next()) : null)
|
|
|
@@ -633,7 +633,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
|
|
|
@Override
|
|
|
public Future<List<Long>> findUnitIdsByCampaignId(long campaignId) {
|
|
|
- return client.preparedQuery("SELECT unit_id FROM maplog.unit_to_campaign WHERE camp_id = $1 ORDER BY unit_id")
|
|
|
+ return client.preparedQuery("SELECT unit_id FROM maplog.unit_to_campaign WHERE campaign_id = $1 ORDER BY unit_id")
|
|
|
.execute(Tuple.of(campaignId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map(r -> r.getLong("unit_id"))
|
|
|
@@ -661,7 +661,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
tupleParams = Tuple.of(campaignId, offset, limit, zone.getId());
|
|
|
}
|
|
|
|
|
|
- String sql = "SELECT tel.obs_id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
+ String sql = "SELECT tel.id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
"tel.time_stamp, $4 AS zone_id, " + // ::timestamp with time zone at time zone $4 AS time_stamp
|
|
|
"ST_X (ST_Transform (tel.the_geom, 4326)) AS long, " +
|
|
|
"ST_Y (ST_Transform (tel.the_geom, 4326)) AS lat, " +
|
|
|
@@ -669,15 +669,15 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
"ST_M (tel.the_geom) AS angle " +
|
|
|
"FROM maplog.obs_telemetry AS tel " +
|
|
|
"JOIN maplog.unit_to_campaign AS utc ON tel.unit_id = utc.unit_id " +
|
|
|
- "JOIN maplog.campaign AS c ON c.campaign_id = utc.camp_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND " + whereTimestampClause + " " +
|
|
|
+ "JOIN maplog.campaign AS c ON c.id = utc.campaign_id " +
|
|
|
+ "WHERE utc.campaign_id = $1 AND " + whereTimestampClause + " " +
|
|
|
"ORDER BY tel.time_stamp OFFSET $2 LIMIT $3;";
|
|
|
|
|
|
return client.preparedQuery(sql)
|
|
|
.execute(tupleParams)
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map(r -> UnitTelemetry.of(
|
|
|
- r.getLong("obs_id"),
|
|
|
+ r.getLong("id"),
|
|
|
r.getLong("unit_id"),
|
|
|
r.getOffsetDateTime("time_stamp"),
|
|
|
Location.of(
|
|
|
@@ -726,7 +726,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
tupleParams = Tuple.of(campaignId, unitId, offset, limit, zone.getId());
|
|
|
}
|
|
|
|
|
|
- String sql = "SELECT tel.obs_id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
+ String sql = "SELECT tel.id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
"tel.time_stamp, $5 AS zone_id, " + // ::timestamp with time zone at time zone $5 AS time_stamp
|
|
|
"ST_X (ST_Transform (tel.the_geom, 4326)) AS long, " +
|
|
|
"ST_Y (ST_Transform (tel.the_geom, 4326)) AS lat, " +
|
|
|
@@ -734,14 +734,14 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
"ST_M (tel.the_geom) AS angle " +
|
|
|
"FROM maplog.obs_telemetry AS tel " +
|
|
|
"JOIN maplog.unit_to_campaign utc on tel.unit_id = utc.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND utc.unit_id = $2 AND " + whereTimestampClause + " " +
|
|
|
+ "WHERE utc.campaign_id = $1 AND utc.unit_id = $2 AND " + whereTimestampClause + " " +
|
|
|
"ORDER BY tel.time_stamp OFFSET $3 LIMIT $4;";
|
|
|
|
|
|
return client.preparedQuery(sql)
|
|
|
.execute(tupleParams)
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map(r -> UnitTelemetry.of(
|
|
|
- r.getLong("obs_id"),
|
|
|
+ r.getLong("id"),
|
|
|
r.getLong("unit_id"),
|
|
|
r.getOffsetDateTime("time_stamp"),
|
|
|
Location.of(
|
|
|
@@ -789,7 +789,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
tupleParams = Tuple.of(eventId, offset, limit, zone.getId());
|
|
|
}
|
|
|
|
|
|
- String sql = "SELECT tel.obs_id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
+ String sql = "SELECT tel.id, tel.unit_id, tel.observed_values::json, tel.speed, " +
|
|
|
"tel.time_stamp, $4 AS zone_id, " + // ::timestamp with time zone at time zone $4 AS time_stamp
|
|
|
"ST_X (ST_Transform (tel.the_geom, 4326)) AS long, " +
|
|
|
"ST_Y (ST_Transform (tel.the_geom, 4326)) AS lat, " +
|
|
|
@@ -804,7 +804,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.execute(tupleParams)
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map(r -> UnitTelemetry.of(
|
|
|
- r.getLong("obs_id"),
|
|
|
+ r.getLong("id"),
|
|
|
r.getLong("unit_id"),
|
|
|
r.getOffsetDateTime("time_stamp"),
|
|
|
Location.of(
|
|
|
@@ -852,7 +852,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
tupleParams = Tuple.of(campaignId, unitId, sensorId, offset, limit, zone.getId());
|
|
|
}
|
|
|
|
|
|
- String sql = "SELECT tel.obs_id, (tel.observed_values::jsonb ->> $3::bigint::text::varchar)::integer AS value, tel.speed, " +
|
|
|
+ String sql = "SELECT tel.id, (tel.observed_values::jsonb ->> $3::bigint::text::varchar)::integer AS value, tel.speed, " +
|
|
|
"tel.time_stamp, $6 AS zone_id, " + // ::timestamp with time zone at time zone $6 AS time_stamp
|
|
|
"ST_X (ST_Transform (tel.the_geom, 4326)) AS long, " +
|
|
|
"ST_Y (ST_Transform (tel.the_geom, 4326)) AS lat, " +
|
|
|
@@ -861,14 +861,14 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
"FROM maplog.obs_telemetry AS tel " +
|
|
|
"JOIN maplog.unit_to_sensor uts on tel.unit_id = uts.unit_id " +
|
|
|
"JOIN maplog.unit_to_campaign utc on tel.unit_id = utc.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND utc.unit_id = $2 AND uts.sensor_id = $3 AND observed_values::jsonb -> $3::bigint::text::varchar IS NOT NULL " +
|
|
|
+ "WHERE utc.campaign_id = $1 AND utc.unit_id = $2 AND uts.sensor_id = $3 AND observed_values::jsonb -> $3::bigint::text::varchar IS NOT NULL " +
|
|
|
"AND " + whereTimestampClause + " ORDER BY tel.time_stamp OFFSET $4 LIMIT $5";
|
|
|
|
|
|
return client.preparedQuery(sql)
|
|
|
.execute(tupleParams)
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
.map(r -> SensorTelemetry.of(
|
|
|
- r.getLong("obs_id"),
|
|
|
+ r.getLong("id"),
|
|
|
r.getLong("value"),
|
|
|
r.getOffsetDateTime("time_stamp"),
|
|
|
Location.of(
|
|
|
@@ -922,7 +922,7 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
"FROM maplog.obs_telemetry AS tel " +
|
|
|
"JOIN maplog.unit u on u.unit_id = tel.unit_id " +
|
|
|
"JOIN maplog.unit_to_campaign utc on tel.unit_id = utc.unit_id " +
|
|
|
- "WHERE utc.camp_id = $1 AND utc.unit_id = $2 AND " + whereTimestampClause + " " +
|
|
|
+ "WHERE utc.campaign_id = $1 AND utc.unit_id = $2 AND " + whereTimestampClause + " " +
|
|
|
"ORDER BY tel.time_stamp OFFSET $3 LIMIT $4;";
|
|
|
|
|
|
return client.preparedQuery(sql)
|
|
|
@@ -1021,16 +1021,16 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
String whereTimestampClause;
|
|
|
Tuple tupleParams;
|
|
|
if (from != null && to != null) {
|
|
|
- whereTimestampClause = "WHERE utc.camp_id = $1 AND time_stamp >= $4 AND time_stamp < $5";
|
|
|
+ whereTimestampClause = "WHERE utc.campaign_id = $1 AND time_stamp >= $4 AND time_stamp < $5";
|
|
|
tupleParams = Tuple.of(campaignId, limitPerUnit, zone.getId(), from, to);
|
|
|
} else if (from != null) {
|
|
|
- whereTimestampClause = "WHERE utc.camp_id = $1 AND time_stamp >= $4";
|
|
|
+ whereTimestampClause = "WHERE utc.campaign_id = $1 AND time_stamp >= $4";
|
|
|
tupleParams = Tuple.of(campaignId, limitPerUnit, zone.getId(), from);
|
|
|
} else if (to != null) {
|
|
|
- whereTimestampClause = "WHERE utc.camp_id = $1 AND time_stamp < $4";
|
|
|
+ whereTimestampClause = "WHERE utc.campaign_id = $1 AND time_stamp < $4";
|
|
|
tupleParams = Tuple.of(campaignId, limitPerUnit, zone.getId(), to);
|
|
|
} else {
|
|
|
- whereTimestampClause = "WHERE utc.camp_id = $1";
|
|
|
+ whereTimestampClause = "WHERE utc.campaign_id = $1";
|
|
|
tupleParams = Tuple.of(campaignId, limitPerUnit, zone.getId());
|
|
|
}
|
|
|
|