From 3fe36628eb344540bdf0ffe50670065bffeaf7a6 Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 20 Dec 2023 15:06:55 +0200 Subject: [PATCH 1/4] Update Docker image for `jore4-hasura` service. --- docker/docker-compose.custom.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.custom.yml b/docker/docker-compose.custom.yml index 7f453b9c..f179da19 100644 --- a/docker/docker-compose.custom.yml +++ b/docker/docker-compose.custom.yml @@ -43,6 +43,6 @@ services: jore4-hasura: # pin compatible version of jore4 data model - image: "hsldevcom/jore4-hasura:hsl-main--20230727-1617be0cc2799bc0ebb70107f7a6d83915c2bfb1" + image: "hsldevcom/jore4-hasura:hsl-main--20231218-8a28ef5f4b22b6351312788be4e674144f2bb0a2" networks: jore4: From 9f133d5bc7d8e3523d963e60b4ff42fb500ede12 Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 20 Dec 2023 15:55:59 +0200 Subject: [PATCH 2/4] Apply different SQL formatting to `export_routes.sql`. --- .../resources/jore4-export/export_routes.sql | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/resources/jore4-export/export_routes.sql b/src/main/resources/jore4-export/export_routes.sql index 9e767eeb..fbeab8f0 100644 --- a/src/main/resources/jore4-export/export_routes.sql +++ b/src/main/resources/jore4-export/export_routes.sql @@ -1,13 +1,14 @@ -SELECT r.network_route_name AS name, - r.network_route_number AS route_number, - r.network_route_hidden_variant AS hidden_variant, - rd.network_route_direction_id AS direction_id, - rd.network_route_direction_type AS direction_type, - l.network_line_jore4_id AS line_jore4_id, - rd.network_route_direction_valid_date_range AS valid_date_range, - r.network_route_legacy_hsl_municipality_code AS legacy_hsl_municipality_code - FROM network.network_routes r - JOIN network.network_route_directions rd ON (rd.network_route_id = r.network_route_id) - JOIN network.network_lines l ON (l.network_line_id = r.network_line_id) - WHERE isempty(rd.network_route_direction_valid_date_range * '[2021-01-01, 2050-01-01)'::daterange) = false - ORDER BY rd.network_route_direction_valid_date_range DESC +SELECT + r.network_route_name AS name, + r.network_route_number AS route_number, + r.network_route_hidden_variant AS hidden_variant, + rd.network_route_direction_id AS direction_id, + rd.network_route_direction_type AS direction_type, + l.network_line_jore4_id AS line_jore4_id, + rd.network_route_direction_valid_date_range AS valid_date_range, + r.network_route_legacy_hsl_municipality_code AS legacy_hsl_municipality_code +FROM network.network_routes r +JOIN network.network_route_directions rd ON (rd.network_route_id = r.network_route_id) +JOIN network.network_lines l ON (l.network_line_id = r.network_line_id) +WHERE isempty(rd.network_route_direction_valid_date_range * '[2021-01-01, 2050-01-01)'::daterange) = false +ORDER BY rd.network_route_direction_valid_date_range DESC From d4c22fe3f1d711391f5b992a4ca189735743093b Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 20 Dec 2023 16:01:53 +0200 Subject: [PATCH 3/4] Change property order to be more logical in `ImporterRoute`. --- .../importer/feature/batch/route/RouteExportMapper.java | 4 ++-- .../importer/feature/network/route/dto/ImporterRoute.java | 8 ++++---- .../feature/batch/route/RouteExportProcessorTest.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportMapper.java b/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportMapper.java index 5fd5e978..1b0911b6 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportMapper.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportMapper.java @@ -31,12 +31,12 @@ public RouteExportMapper(final IJsonbConverter jsonConverter) { @Override public ImporterRoute mapRow(final ResultSet resultSet, final int rowNumber) throws SQLException { return ImporterRoute.of( + resultSet.getString("route_number"), + getOptionalShort(resultSet, "hidden_variant"), UUID.fromString(resultSet.getString("direction_id")), DirectionType.of(resultSet.getString("direction_type")), jsonConverter.fromJson(resultSet.getString("name"), MultilingualString.class), UUID.fromString(resultSet.getString("line_jore4_id")), - resultSet.getString("route_number"), - getOptionalShort(resultSet, "hidden_variant"), DATE_RANGE_CONVERTER.from(resultSet.getString("valid_date_range")), LegacyHslMunicipalityCode.valueOf(resultSet.getString("legacy_hsl_municipality_code")) ); diff --git a/src/main/java/fi/hsl/jore/importer/feature/network/route/dto/ImporterRoute.java b/src/main/java/fi/hsl/jore/importer/feature/network/route/dto/ImporterRoute.java index 2503476a..8d1ba559 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/network/route/dto/ImporterRoute.java +++ b/src/main/java/fi/hsl/jore/importer/feature/network/route/dto/ImporterRoute.java @@ -32,13 +32,13 @@ public interface ImporterRoute { LegacyHslMunicipalityCode legacyHslMunicipalityCode(); - static ImporterRoute of(final UUID directionId, + static ImporterRoute of(final String routeNumber, + final Optional hiddenVariant, + final UUID directionId, final DirectionType directionType, final MultilingualString name, final UUID lineJore4Id, - final String routeNumber, - final Optional hiddenVariant, - final DateRange validDateRange, + final DateRange validDateRange, final LegacyHslMunicipalityCode legacyHslMunicipalityCode) { return ImmutableImporterRoute.builder() .directionId(directionId) diff --git a/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessorTest.java b/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessorTest.java index 245128bb..f547bc3c 100644 --- a/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessorTest.java +++ b/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessorTest.java @@ -33,12 +33,12 @@ class RouteExportProcessorTest { private static final LegacyHslMunicipalityCode ROUTE_LEGACY_HSL_MUNICIPALITY_CODE = LegacyHslMunicipalityCode.HELSINKI; private static final ImporterRoute INPUT = ImporterRoute.of( + ROUTE_NUMBER, + ROUTE_HIDDEN_VARIANT, IMPORTER_ROUTE_DIRECTION_ID, IMPORTER_ROUTE_DIRECTION, createMultilingualString(FINNISH_NAME, SWEDISH_NAME), LINE_JORE4_ID, - ROUTE_NUMBER, - ROUTE_HIDDEN_VARIANT, DateRange.between(VALIDITY_PERIOD_START_DAY, VALIDITY_PERIOD_END_DAY), ROUTE_LEGACY_HSL_MUNICIPALITY_CODE ); From ab031d87b3d2125819876c9130c95286f0d2b59b Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 20 Dec 2023 15:56:30 +0200 Subject: [PATCH 4/4] Fix route description in export. Use the name of Jore3 route direction as the source instead of route. Resolves HSLdevcom/jore4#1604 --- src/main/resources/jore4-export/export_routes.sql | 8 ++++---- .../jore/importer/config/jobs/ExportRouteStepTest.java | 2 +- .../feature/batch/route/RouteExportReaderTest.java | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/jore4-export/export_routes.sql b/src/main/resources/jore4-export/export_routes.sql index fbeab8f0..9749565b 100644 --- a/src/main/resources/jore4-export/export_routes.sql +++ b/src/main/resources/jore4-export/export_routes.sql @@ -1,14 +1,14 @@ SELECT - r.network_route_name AS name, r.network_route_number AS route_number, r.network_route_hidden_variant AS hidden_variant, rd.network_route_direction_id AS direction_id, rd.network_route_direction_type AS direction_type, + rd.network_route_direction_name AS name, l.network_line_jore4_id AS line_jore4_id, rd.network_route_direction_valid_date_range AS valid_date_range, r.network_route_legacy_hsl_municipality_code AS legacy_hsl_municipality_code FROM network.network_routes r -JOIN network.network_route_directions rd ON (rd.network_route_id = r.network_route_id) -JOIN network.network_lines l ON (l.network_line_id = r.network_line_id) -WHERE isempty(rd.network_route_direction_valid_date_range * '[2021-01-01, 2050-01-01)'::daterange) = false +JOIN network.network_route_directions rd USING (network_route_id) +JOIN network.network_lines l USING (network_line_id) +WHERE NOT isempty(rd.network_route_direction_valid_date_range * '[2021-01-01, 2050-01-01)'::daterange) ORDER BY rd.network_route_direction_valid_date_range DESC diff --git a/src/test/java/fi/hsl/jore/importer/config/jobs/ExportRouteStepTest.java b/src/test/java/fi/hsl/jore/importer/config/jobs/ExportRouteStepTest.java index 050b8c6d..61273c71 100644 --- a/src/test/java/fi/hsl/jore/importer/config/jobs/ExportRouteStepTest.java +++ b/src/test/java/fi/hsl/jore/importer/config/jobs/ExportRouteStepTest.java @@ -53,7 +53,7 @@ public class ExportRouteStepTest extends BatchIntegrationTest { private final String EXPECTED_DIRECTION = Jore4RouteDirection.INBOUND.getValue(); private final UUID EXPECTED_LINE_JORE4_ID = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); private static final String EXPECTED_LABEL = "1"; - private static final String EXPECTED_DESCRIPTION = "{\"fi_FI\":\"Keskustori - Etelä-Hervanta vanha\",\"sv_SE\":\"Central torget - Södra Hervanta gamla\"}"; + private static final String EXPECTED_DESCRIPTION = "{\"fi_FI\":\"Keskustori - Kaleva - Etelä-Hervanta vanha\",\"sv_SE\":\"Central torget - Kaleva - Södra Hervanta gamla\"}"; private static final int EXPECTED_PRIORITY = 10; private static final LegacyHslMunicipalityCode EXPECTED_LEGACY_HSL_MUNICIPALITY_CODE = LegacyHslMunicipalityCode.HELSINKI; diff --git a/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportReaderTest.java b/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportReaderTest.java index 3a54fdde..9a1ec081 100644 --- a/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportReaderTest.java +++ b/src/test/java/fi/hsl/jore/importer/feature/batch/route/RouteExportReaderTest.java @@ -76,8 +76,8 @@ class WhenSourceTableHasOneRoute { private final DirectionType EXPECTED_DIRECTION_TYPE = DirectionType.INBOUND; private final UUID EXPECTED_LINE_JORE4_ID = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); private static final String EXPECTED_ROUTE_NUMBER = "1"; - private static final String EXPECTED_FINNISH_NAME = "Keskustori - Etelä-Hervanta vanha"; - private static final String EXPECTED_SWEDISH_NAME = "Central torget - Södra Hervanta gamla"; + private static final String EXPECTED_FINNISH_NAME = "Keskustori - Kaleva - Etelä-Hervanta vanha"; + private static final String EXPECTED_SWEDISH_NAME = "Central torget - Kaleva - Södra Hervanta gamla"; private final LocalDate EXPECTED_VALID_DATE_RANGE_START = LocalDate.of(2021, 1, 1); private final LocalDate EXPECTED_VALID_DATE_RANGE_END = LocalDate.of(2022, 1, 1);