diff --git a/README.md b/README.md index f4157244e6c50810b621872c5eea948dfa038051..178122ce7eb8ee703017675c30237e8eda4adac3 100644 --- a/README.md +++ b/README.md @@ -136,24 +136,53 @@ for (final Area area : areas){ } ``` -### Finding Destinations by service identifier and region +### Finding Destinations -For searching a destination the `DestinationSearch.Builder` is used pass a search request to the routing client. -The leikaKey is mandatory, as well as (max.) one other search criterion for the area/region, like one of: -- ars amtlicher regionalschlüssel -- ags amtlicher gemeindeschlüssel -- areaId identifier of an area that can be retrieved via [finding areas](#finding-areas) +For searching a destination the `DestinationSearch.Builder` is used pass a search request to the routing client. +The `leikaKey` is mandatory, as well as (max.) one other search criterion for the area/region, like one of: +- *areaId* = identifier of an area that can be retrieved via [findAreas(...)](#finding-areas) of the routing client +- ARS = *amtlicher Regionalschlüssel* +- AGS = *amtlicher Gemeindeschlüssel* + +__Note:__ Both, the `leikaKey` service-identifier and the region keys `ars/ags`cannot be retrieved via the routing client, but can be found here: +- [https://fimportal.de/](https://fimportal.de/) catalog for finding leikaKey service identifier +- [https://opengovtech.de/](https://opengovtech.de/ars/) for looking up regional keys + + +#### Find destination by service identifier and *areaId* + +```java +final RoutingClient routingClient = ClientFactory.routingClient(config); + +final DestinationSearch search = DestinationSearch.Builder() + .withLeikaKey("99123456760610") + .withAreaId("48566") // areaId of "Leipzig" + .withLimit(3) + .build(); + +// get first 3 route results +final List<Route> routes = routingClient.findDestinations(search); + +LOGGER.info("Found {} routes for service identifier {}", routes.size(), leikaKey); +for (final Route route : routes){ + LOGGER.info("Route {} with destinationId {} found", route.getName(), route.getDestinationId()); +} +``` + +#### Find destination by service identifier and region key (ARS/AGS) + +Besides the areaId another search criterion for the area/region can be used as well: ```java final RoutingClient routingClient = ClientFactory.routingClient(config); final DestinationSearch search = DestinationSearch.Builder() .withLeikaKey("99123456760610") - .withArs("064350014014") - .withLimit(5) + .withArs("147130000000") // example ars for "Leipzig" + .withLimit(3) .build(); -// get first 5 route results +// get first 3 route results final List<Route> routes = routingClient.findDestinations(search); LOGGER.info("Found {} routes for service identifier {}", routes.size(), leikaKey); diff --git a/api/pom.xml b/api/pom.xml index 59e29c830a4f26dacda8d669d6cc1d2f1b3bb948..60bee28c928f4521f4dc7f9a1c843c93dab94564 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -34,10 +34,6 @@ <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> - <dependency> - <groupId>org.projectlombok</groupId> - <artifactId>lombok</artifactId> - </dependency> </dependencies> <build> diff --git a/client/src/main/java/dev/fitko/fitconnect/client/factory/ApplicationConfigLoader.java b/client/src/main/java/dev/fitko/fitconnect/client/factory/ApplicationConfigLoader.java index d6c67ce20d9cca49a4dbde93192007344e6c5b8c..09269e0bf79d9a27cb06cb8140a4b8c36d7d7acd 100644 --- a/client/src/main/java/dev/fitko/fitconnect/client/factory/ApplicationConfigLoader.java +++ b/client/src/main/java/dev/fitko/fitconnect/client/factory/ApplicationConfigLoader.java @@ -4,9 +4,9 @@ import dev.fitko.fitconnect.api.config.ApplicationConfig; import dev.fitko.fitconnect.api.config.BuildInfo; import dev.fitko.fitconnect.api.exceptions.InitializationException; import org.yaml.snakeyaml.Yaml; -import org.yaml.snakeyaml.constructor.Constructor; import java.io.IOException; +import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; @@ -50,11 +50,7 @@ public final class ApplicationConfigLoader { * @return ApplicationConfig */ public static ApplicationConfig loadConfigFromYaml(final String configYaml) { - - final Yaml applicationPropertiesYaml = new Yaml(new Constructor(ApplicationConfig.class)); - final ApplicationConfig applicationConfig = applicationPropertiesYaml.load(configYaml); - - return applicationConfig; + return new Yaml().loadAs(configYaml, ApplicationConfig.class); } /** @@ -63,9 +59,7 @@ public final class ApplicationConfigLoader { * @return {@link BuildInfo} */ public static BuildInfo loadBuildInfo() { - - final Yaml buildInfoYaml = new Yaml(new Constructor(BuildInfo.class)); - - return buildInfoYaml.load(ApplicationConfigLoader.class.getClassLoader().getResourceAsStream(BUILD_INFO_PATH)); + final InputStream resource = ApplicationConfigLoader.class.getClassLoader().getResourceAsStream(BUILD_INFO_PATH); + return new Yaml().loadAs(resource, BuildInfo.class); } } diff --git a/pom.xml b/pom.xml index fd22e0d8fa5227dbd50392c4e31e9c35dd1925c5..809ecb3d97044cb5c40c90bc746da2078109f40a 100644 --- a/pom.xml +++ b/pom.xml @@ -69,16 +69,16 @@ <jcommander.version>1.82</jcommander.version> <apache-tika.version>2.7.0</apache-tika.version> <spring-web.version>5.3.25</spring-web.version> - <snakeyaml.version>1.33</snakeyaml.version> + <snakeyaml.version>2.0</snakeyaml.version> <open-csv.version>5.7.1</open-csv.version> - <json-schema-validator.version>1.0.77</json-schema-validator.version> + <json-schema-validator.version>1.0.78</json-schema-validator.version> <junit.version>5.9.2</junit.version> <mockito.version>5.1.1</mockito.version> <wiremock.version>2.27.2</wiremock.version> <hamcrest.version>1.3</hamcrest.version> <awaitility-version>4.2.0</awaitility-version> - <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> + <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version> <maven-surefire-plugin.version>3.0.0-M9</maven-surefire-plugin.version> <maven-failsafe-plugin.version>3.0.0-M9</maven-failsafe-plugin.version> <maven-checkstyle-plugin.version>3.2.1</maven-checkstyle-plugin.version>