From 100dcfb07a4653cace32432fb61880361e80c340 Mon Sep 17 00:00:00 2001 From: Jarkko Kaura Date: Wed, 3 Jan 2024 16:55:59 +0200 Subject: [PATCH] Apply different variable naming in order to better distinguish columns between different databases. --- .../feature/batch/line/LineExportMapper.java | 6 +++--- .../batch/line/LineExportProcessor.java | 2 +- .../feature/batch/line/LineExportWriter.java | 2 +- .../line/support/LineImportRepository.java | 4 ++-- .../batch/route/RouteExportMapper.java | 2 +- .../batch/route/RouteExportProcessor.java | 2 +- .../feature/jore4/entity/Jore4Line.java | 10 +++++----- .../network/line/dto/ImporterLine.java | 10 +++++----- .../line/dto/PersistableLineIdMapping.java | 19 +++++++++---------- .../network/route/dto/ImporterRoute.java | 9 ++++----- .../resources/jore4-export/export_lines.sql | 6 +++--- .../resources/jore4-export/export_routes.sql | 2 +- .../config/jobs/ExportRouteStepTest.java | 6 +++--- .../batch/line/LineExportProcessorTest.java | 8 ++++---- .../batch/line/LineExportReaderTest.java | 8 ++++---- .../batch/route/RouteExportProcessorTest.java | 10 +++++----- .../batch/route/RouteExportReaderTest.java | 8 ++++---- 17 files changed, 56 insertions(+), 58 deletions(-) diff --git a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportMapper.java b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportMapper.java index b8a2728c..d10399c5 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportMapper.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportMapper.java @@ -32,10 +32,10 @@ public ImporterLine mapRow(final ResultSet resultSet, final int rowNumber) throw return ImporterLine.of( ExternalId.of(resultSet.getString("external_id")), resultSet.getString("line_number"), - jsonConverter.fromJson(resultSet.getString("name"), MultilingualString.class), + jsonConverter.fromJson(resultSet.getString("line_header_name"), MultilingualString.class), NetworkType.of(resultSet.getString("network_type")), - jsonConverter.fromJson(resultSet.getString("short_name"), MultilingualString.class), - DATE_RANGE_CONVERTER.from(resultSet.getString("valid_date_range")), + jsonConverter.fromJson(resultSet.getString("line_header_short_name"), MultilingualString.class), + DATE_RANGE_CONVERTER.from(resultSet.getString("line_header_valid_date_range")), TypeOfLine.of(resultSet.getString("type_of_line")), LegacyHslMunicipalityCode.valueOf(resultSet.getString("legacy_hsl_municipality_code")) ); diff --git a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessor.java b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessor.java index 91b6fb82..2f82427c 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessor.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessor.java @@ -28,7 +28,7 @@ public Jore4Line process(final ImporterLine input) throws Exception { return Jore4Line.of( UUID.randomUUID(), - input.externalId().value(), + input.externalIdOfLine().value(), input.lineNumber(), input.name(), input.shortName(), diff --git a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportWriter.java b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportWriter.java index 297cb8bb..98629e63 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportWriter.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/line/LineExportWriter.java @@ -32,7 +32,7 @@ public void write(final List items) throws Exception { final io.vavr.collection.List jore4IdMappings = items.stream() .map(item -> PersistableLineIdMapping.of( - item.externalLineId(), + item.externalIdOfLine(), item.lineId() )) .collect(io.vavr.collection.List.collector()); diff --git a/src/main/java/fi/hsl/jore/importer/feature/batch/line/support/LineImportRepository.java b/src/main/java/fi/hsl/jore/importer/feature/batch/line/support/LineImportRepository.java index 6b85b888..89a36296 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/line/support/LineImportRepository.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/line/support/LineImportRepository.java @@ -109,8 +109,8 @@ public void setJore4Ids(final List idMappings) { db.batched(c -> { idMappings.forEach(idMapping -> { c.dsl().update(TARGET_TABLE) - .set(TARGET_TABLE.NETWORK_LINE_JORE4_ID, idMapping.jore4Id()) - .where(TARGET_TABLE.NETWORK_LINE_EXT_ID.eq(idMapping.externalId())) + .set(TARGET_TABLE.NETWORK_LINE_JORE4_ID, idMapping.jore4IdOfLine()) + .where(TARGET_TABLE.NETWORK_LINE_EXT_ID.eq(idMapping.externalIdOfLine())) .execute(); }); }); 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 1b0911b6..1da014d5 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 @@ -36,7 +36,7 @@ public ImporterRoute mapRow(final ResultSet resultSet, final int rowNumber) thro 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")), + UUID.fromString(resultSet.getString("jore4_id_of_line")), 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/batch/route/RouteExportProcessor.java b/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessor.java index 77299a6e..9056b989 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessor.java +++ b/src/main/java/fi/hsl/jore/importer/feature/batch/route/RouteExportProcessor.java @@ -33,7 +33,7 @@ public Jore4Route process(final ImporterRoute input) throws Exception { input.directionId(), input.routeNumber(), input.hiddenVariant(), - input.lineJore4Id(), + input.jore4IdOfLine(), DEFAULT_PRIORITY, ValidityPeriodUtil.constructValidityPeriodStartDay(input.validDateRange().range()), ValidityPeriodUtil.constructValidityPeriodEndDay(input.validDateRange().range()), diff --git a/src/main/java/fi/hsl/jore/importer/feature/jore4/entity/Jore4Line.java b/src/main/java/fi/hsl/jore/importer/feature/jore4/entity/Jore4Line.java index 05cf9562..03a131ac 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/jore4/entity/Jore4Line.java +++ b/src/main/java/fi/hsl/jore/importer/feature/jore4/entity/Jore4Line.java @@ -8,15 +8,15 @@ import java.util.UUID; /** - * Contains the information of a line which can - * inserted into the Jore 4 transmodel schema. + * Contains the information of a line which can inserted into the Jore 4 + * Transmodel schema. */ @Value.Immutable public interface Jore4Line { UUID lineId(); - String externalLineId(); + String externalIdOfLine(); String label(); @@ -37,7 +37,7 @@ public interface Jore4Line { LegacyHslMunicipalityCode legacyHslMunicipalityCode(); static ImmutableJore4Line of(final UUID lineId, - final String externalLineId, + final String externalIdOfLine, final String label, final MultilingualString name, final MultilingualString shortName, @@ -49,7 +49,7 @@ static ImmutableJore4Line of(final UUID lineId, final LegacyHslMunicipalityCode legacyHslMunicipalityCode) { return ImmutableJore4Line.builder() .lineId(lineId) - .externalLineId(externalLineId) + .externalIdOfLine(externalIdOfLine) .label(label) .name(name) .shortName(shortName) diff --git a/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/ImporterLine.java b/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/ImporterLine.java index 37b9b609..6cb453ec 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/ImporterLine.java +++ b/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/ImporterLine.java @@ -9,13 +9,13 @@ import org.immutables.value.Value; /** - * Contains the information of a line which is required when - * we want to export lines to the Jore 4 transmodel schema. + * Contains the information of a line that is required when + * we want to export lines to the Jore 4 Transmodel schema. */ @Value.Immutable public interface ImporterLine { - ExternalId externalId(); + ExternalId externalIdOfLine(); String lineNumber(); @@ -31,7 +31,7 @@ public interface ImporterLine { LegacyHslMunicipalityCode legacyHslMunicipalityCode(); - static ImmutableImporterLine of (final ExternalId externalId, + static ImmutableImporterLine of (final ExternalId externalIdOfLine, final String lineNumber, final MultilingualString name, final NetworkType networkType, @@ -40,7 +40,7 @@ static ImmutableImporterLine of (final ExternalId externalId, final TypeOfLine typeOfLine, final LegacyHslMunicipalityCode legacyHslMunicipalityCode) { return ImmutableImporterLine.builder() - .externalId(externalId) + .externalIdOfLine(externalIdOfLine) .lineNumber(lineNumber) .name(name) .networkType(networkType) diff --git a/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/PersistableLineIdMapping.java b/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/PersistableLineIdMapping.java index 55fb6bca..c5e01b49 100644 --- a/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/PersistableLineIdMapping.java +++ b/src/main/java/fi/hsl/jore/importer/feature/network/line/dto/PersistableLineIdMapping.java @@ -5,23 +5,22 @@ import java.util.UUID; /** - * Contains the information that's required to update - * the Jore 4 id (primary key of a line found from - * Jore 4 database) of a line stored in the database - * of the importer application. + * Contains the information that's required to update the Jore 4 ID (primary + * key of a line found from the Jore 4 database) of a line stored in the + * database of the importer application. */ @Value.Immutable public interface PersistableLineIdMapping { - String externalId(); + String externalIdOfLine(); - UUID jore4Id(); + UUID jore4IdOfLine(); - static PersistableLineIdMapping of(final String externalId, - final UUID jore4Id) { + static PersistableLineIdMapping of(final String externalIdOfLine, + final UUID jore4IdOfLine) { return ImmutablePersistableLineIdMapping.builder() - .externalId(externalId) - .jore4Id(jore4Id) + .externalIdOfLine(externalIdOfLine) + .jore4IdOfLine(jore4IdOfLine) .build(); } } 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 8d1ba559..812ca2ea 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 @@ -10,8 +10,7 @@ import java.util.UUID; /** - * Contains the source data of a route which is exported - * to the Jore 4 database. + * Contains the source data of a route which is exported to the Jore 4 database. */ @Value.Immutable public interface ImporterRoute { @@ -22,7 +21,7 @@ public interface ImporterRoute { MultilingualString name(); - UUID lineJore4Id(); + UUID jore4IdOfLine(); String routeNumber(); @@ -37,14 +36,14 @@ static ImporterRoute of(final String routeNumber, final UUID directionId, final DirectionType directionType, final MultilingualString name, - final UUID lineJore4Id, + final UUID jore4IdOfLine, final DateRange validDateRange, final LegacyHslMunicipalityCode legacyHslMunicipalityCode) { return ImmutableImporterRoute.builder() .directionId(directionId) .directionType(directionType) .name(name) - .lineJore4Id(lineJore4Id) + .jore4IdOfLine(jore4IdOfLine) .routeNumber(routeNumber) .hiddenVariant(hiddenVariant) .validDateRange(validDateRange) diff --git a/src/main/resources/jore4-export/export_lines.sql b/src/main/resources/jore4-export/export_lines.sql index 866dcc35..7605ca19 100644 --- a/src/main/resources/jore4-export/export_lines.sql +++ b/src/main/resources/jore4-export/export_lines.sql @@ -12,9 +12,9 @@ SELECT l.infrastructure_network_type AS network_type, l.network_line_type_of_line AS type_of_line, l.network_line_legacy_hsl_municipality_code AS legacy_hsl_municipality_code, - lh.network_line_header_name AS name, - lh.network_line_header_name_short AS short_name, - lh.network_line_header_valid_date_range AS valid_date_range + lh.network_line_header_name AS line_header_name, + lh.network_line_header_name_short AS line_header_short_name, + lh.network_line_header_valid_date_range AS line_header_valid_date_range FROM network.network_lines l JOIN network.network_line_headers lh USING (network_line_id) WHERE diff --git a/src/main/resources/jore4-export/export_routes.sql b/src/main/resources/jore4-export/export_routes.sql index 4d9ca381..4bf6fdf8 100644 --- a/src/main/resources/jore4-export/export_routes.sql +++ b/src/main/resources/jore4-export/export_routes.sql @@ -13,7 +13,7 @@ SELECT 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, + l.network_line_jore4_id AS jore4_id_of_line, 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 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 61273c71..d3d913c7 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 @@ -51,7 +51,7 @@ public class ExportRouteStepTest extends BatchIntegrationTest { private static final List STEPS = List.of("exportRoutesStep"); private final String EXPECTED_DIRECTION = Jore4RouteDirection.INBOUND.getValue(); - private final UUID EXPECTED_LINE_JORE4_ID = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); + private final UUID EXPECTED_JORE4_ID_OF_LINE = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); private static final String EXPECTED_LABEL = "1"; 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; @@ -131,14 +131,14 @@ void shouldSaveExportedRouteWithCorrectLabel() { } @Test - @DisplayName("Should save the exported route with the correct line id") + @DisplayName("Should save the exported route with the correct line ID") void shouldSaveExportedRouteWithCorrectLineId() { runSteps(STEPS); assertThat(jore4TargetTable) .row() .value(JORE4_ROUTE.ON_LINE_ID.getName()) - .isEqualTo(EXPECTED_LINE_JORE4_ID); + .isEqualTo(EXPECTED_JORE4_ID_OF_LINE); } @Test diff --git a/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessorTest.java b/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessorTest.java index 30446ac7..ce3bcc36 100644 --- a/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessorTest.java +++ b/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportProcessorTest.java @@ -20,7 +20,7 @@ class LineExportProcessorTest { private static final String LINE_NUMBER = "35"; - private static final String EXTERNAL_ID = "7863"; + private static final String EXTERNAL_ID_OF_LINE = "7863"; private static final String FINNISH_NAME = "Vantaanportti-Lentoasema-Kerava"; private static final String FINNISH_SHORT_NAME = "Vantaanp-Kerava"; private static final String SWEDISH_NAME = "Vandaporten-Flygstationen-Kervo"; @@ -36,7 +36,7 @@ class LineExportProcessorTest { private static final int EXPECTED_PRIORITY = 10; private static final ImporterLine INPUT = ImporterLine.of( - ExternalId.of(EXTERNAL_ID), + ExternalId.of(EXTERNAL_ID_OF_LINE), LINE_NUMBER, JoreLocaleUtil.createMultilingualString(FINNISH_NAME, SWEDISH_NAME), NETWORK_TYPE_ROAD, @@ -61,10 +61,10 @@ void shouldReturnLineWithGeneratedId() throws Exception { } @Test - @DisplayName("Should return a line with the correct external id") + @DisplayName("Should return a line with the correct external ID") void shouldReturnLineWithCorrectExternalId() throws Exception { final Jore4Line line = processor.process(INPUT); - assertThat(line.externalLineId()).isEqualTo(EXTERNAL_ID); + assertThat(line.externalIdOfLine()).isEqualTo(EXTERNAL_ID_OF_LINE); } @Test diff --git a/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportReaderTest.java b/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportReaderTest.java index def543c5..4626017b 100644 --- a/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportReaderTest.java +++ b/src/test/java/fi/hsl/jore/importer/feature/batch/line/LineExportReaderTest.java @@ -27,7 +27,7 @@ @IntTest class LineExportReaderTest { - private static final String EXPECTED_EXTERNAL_ID = "1001"; + private static final String EXPECTED_EXTERNAL_ID_OF_LINE = "1001"; private static final String EXPECTED_LINE_NUMBER = "1"; @@ -88,9 +88,9 @@ class WhenSourceTablesHaveOneLine { void firstInvocationOfReadMethodMustReturnFoundLine(final SoftAssertions softAssertions) throws Exception { final ImporterLine line = reader.read(); - softAssertions.assertThat(line.externalId().value()) - .as("externalId") - .isEqualTo(EXPECTED_EXTERNAL_ID); + softAssertions.assertThat(line.externalIdOfLine().value()) + .as("externalIdOfLine") + .isEqualTo(EXPECTED_EXTERNAL_ID_OF_LINE); softAssertions.assertThat(line.lineNumber()) .as("lineNumber") 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 f547bc3c..8a0a934b 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 @@ -25,7 +25,7 @@ class RouteExportProcessorTest { private static final int JORE4_ROUTE_PRIORITY = 10; private static final String FINNISH_NAME = "Keskustori - Etelä-Hervanta"; private static final String SWEDISH_NAME = "Central torget - Södra Hervanta"; - private static final UUID LINE_JORE4_ID = UUID.fromString("184b4710-9366-4500-aef3-39d03e95dde2"); + private static final UUID JORE4_ID_OF_LINE = UUID.fromString("184b4710-9366-4500-aef3-39d03e95dde2"); private static final String ROUTE_NUMBER = "30"; private static final Optional ROUTE_HIDDEN_VARIANT = Optional.of((short)1); private static final LocalDate VALIDITY_PERIOD_START_DAY = LocalDate.of(2021, 1, 1); @@ -38,7 +38,7 @@ class RouteExportProcessorTest { IMPORTER_ROUTE_DIRECTION_ID, IMPORTER_ROUTE_DIRECTION, createMultilingualString(FINNISH_NAME, SWEDISH_NAME), - LINE_JORE4_ID, + JORE4_ID_OF_LINE, DateRange.between(VALIDITY_PERIOD_START_DAY, VALIDITY_PERIOD_END_DAY), ROUTE_LEGACY_HSL_MUNICIPALITY_CODE ); @@ -97,10 +97,10 @@ void shouldReturnRouteWithCorrectHiddenVariantNull() throws Exception { } @Test - @DisplayName("Should return a route with the correct line Jore 4 id") - void shouldReturnRouteWithCorrectLineJore4Id() throws Exception { + @DisplayName("Should return a route with the correct Jore 4 ID of line") + void shouldReturnRouteWithCorrectJore4IdOfLine() throws Exception { final Jore4Route route = processor.process(INPUT); - assertThat(route.lineId()).isEqualTo(LINE_JORE4_ID); + assertThat(route.lineId()).isEqualTo(JORE4_ID_OF_LINE); } @Test 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 a03aca1d..bb7f5596 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 @@ -74,7 +74,7 @@ class WhenSourceTableHasOneRoute { private final UUID EXPECTED_DIRECTION_ID = UUID.fromString("6f93fa6b-8a19-4b98-bd84-b8409e670c70"); private final DirectionType EXPECTED_DIRECTION_TYPE = DirectionType.INBOUND; - private final UUID EXPECTED_LINE_JORE4_ID = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); + private final UUID EXPECTED_JORE4_ID_OF_LINE = UUID.fromString("5aa7d9fc-2cf9-466d-8ac0-f442d60c261f"); private static final String EXPECTED_ROUTE_NUMBER = "1"; 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"; @@ -93,9 +93,9 @@ void firstInvocationOfReadMethodMustReturnFoundRoute(final SoftAssertions softAs softAssertions.assertThat(route.directionType()) .as("directionType") .isEqualTo(EXPECTED_DIRECTION_TYPE); - softAssertions.assertThat(route.lineJore4Id()) - .as("lineJore4Id") - .isEqualTo(EXPECTED_LINE_JORE4_ID); + softAssertions.assertThat(route.jore4IdOfLine()) + .as("jore4IdOfLine") + .isEqualTo(EXPECTED_JORE4_ID_OF_LINE); softAssertions.assertThat(route.routeNumber()) .as("routeNumber") .isEqualTo(EXPECTED_ROUTE_NUMBER);