|
|
@@ -283,13 +283,6 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.map(iterator -> iterator.hasNext() ? ROW_TO_PHENOMENON.apply(iterator.next()) : null);
|
|
|
}
|
|
|
|
|
|
- private static final Function<Row, Campaign> ROW_TO_BASIC_CAMPAIGN = (row) -> Campaign.of(
|
|
|
- row.getLong("campaign_id"),
|
|
|
- row.getString("description"),
|
|
|
- row.getOffsetDateTime("from_time"),
|
|
|
- row.getOffsetDateTime("to_time")
|
|
|
- );
|
|
|
-
|
|
|
@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 " +
|
|
|
@@ -298,7 +291,12 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
"WHERE utc.unit_id = $1")
|
|
|
.execute(Tuple.of(unitId))
|
|
|
.map(rs -> StreamSupport.stream(rs.spliterator(), false)
|
|
|
- .map(ROW_TO_BASIC_CAMPAIGN).collect(Collectors.toList()))
|
|
|
+ .map((row) -> Campaign.of(
|
|
|
+ row.getLong("campaign_id"),
|
|
|
+ row.getString("description"),
|
|
|
+ row.getOffsetDateTime("from_time"),
|
|
|
+ row.getOffsetDateTime("to_time")
|
|
|
+ )).collect(Collectors.toList()))
|
|
|
.onFailure(logger::catching);
|
|
|
}
|
|
|
|
|
|
@@ -314,6 +312,19 @@ public class MapLogRepository implements SensLogRepository {
|
|
|
.onFailure(logger::catching);
|
|
|
}
|
|
|
|
|
|
+ private static final Function<Row, Driver> ROW_TO_DRIVER = (row) -> Driver.of(
|
|
|
+ row.getInteger("id"),
|
|
|
+ row.getString("name")
|
|
|
+ );
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Future<Driver> findDriverById(int driverId) {
|
|
|
+ return client.preparedQuery("SELECT id, name FROM maplog.driver WHERE id = $1")
|
|
|
+ .execute(Tuple.of(driverId))
|
|
|
+ .map(RowSet::iterator)
|
|
|
+ .map(iterator -> iterator.hasNext() ? ROW_TO_DRIVER.apply(iterator.next()) : null);
|
|
|
+ }
|
|
|
+
|
|
|
@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 " +
|