├── .gitignore
├── LICENSE
├── README.md
├── client
├── .gitignore
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── hisrc
│ │ │ └── dbfahrplanapi
│ │ │ └── client
│ │ │ ├── DbFahrplanApiClient.java
│ │ │ ├── DbFahrplanApiException.java
│ │ │ ├── DefaultDbFahrplanApiClient.java
│ │ │ └── invoker
│ │ │ └── CustomizedApiClient.java
│ └── resources
│ │ ├── db-fahrplan-api-specification.yaml
│ │ ├── hafasRestArrivalBoard.xsd
│ │ ├── hafasRestDepartureBoard.xsd
│ │ ├── hafasRestJourneyDetail.xsd
│ │ └── hafasRestLocation.xsd
│ └── test
│ ├── java
│ └── org
│ │ └── hisrc
│ │ └── dbfahrplanapi
│ │ └── client
│ │ ├── api
│ │ └── tests
│ │ │ └── DefaultApiClientTest.java
│ │ ├── model
│ │ └── tests
│ │ │ └── ApiClientMapperTest.java
│ │ └── tests
│ │ └── DbFahrplanApiClientTest.java
│ └── resources
│ ├── .gitignore
│ ├── README.md
│ └── org
│ └── hisrc
│ └── dbfahrplanapi
│ └── client
│ └── model
│ └── tests
│ ├── departure.json
│ ├── journeyDetails.json
│ └── location.json
├── db-fahrplan-api-specification.yaml
├── pom.xml
└── qrelease.bat
/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .project
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Alexey Valikov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Deutsche Bahn Fahrplan API
2 |
3 | This projects provides a [Swagger](http://swagger.io/specification/)/[OpenAPI](https://github.com/OAI/OpenAPI-Specification) specification for the Deutsche Bahn Fahrplan API:
4 |
5 | * [db-fahrplan-api-specification.yaml](https://github.com/highsource/db-fahrplan-api/blob/master/db-fahrplan-api-specification.yaml)
6 |
7 | Additionally, the project also provides a simple Java Client generated using [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) and slightly customized.
8 |
9 | ## Usage
10 |
11 | ### Adding the client to your project
12 |
13 | #### Maven
14 |
15 | Add the following dependency to your project:
16 |
17 | ```xml
18 |
19 | org.hisrc.db-fahrplan-api
20 | db-fahrplan-api-client
21 | ...
22 |
23 | ```
24 |
25 | ### Using the client in your Java code
26 |
27 | #### Creating the client
28 |
29 | ```
30 | DbFahrplanApiClient client = new DefaultDbFahrplanApiClient(authKey);
31 | ```
32 |
33 | #### Querying locations
34 |
35 | ```
36 | List stopLocations = client.locationName("Frankfurt Hbf");
37 | ```
38 |
39 | #### Querying departures or arrivals
40 |
41 | ```
42 | List arrivals = client.arrivalBoard("008000105", LocalDateTime.now());
43 | List departures = client.departureBoard("008000105", LocalDateTime.now());
44 | ```
45 |
46 | #### Querying journey details
47 |
48 | ```
49 | List arrivals = client.arrivalBoard("008000105", LocalDateTime.now());
50 | JourneyDetailRef journeyDetailRef = arrivals.get(0).getJourneyDetailRef();
51 | JourneyDetail journeyDetail = client.journeyDetail(journeyDetailRef);
52 | ```
--------------------------------------------------------------------------------
/client/.gitignore:
--------------------------------------------------------------------------------
1 | .settings
2 | .project
3 | .classpath
4 | target
--------------------------------------------------------------------------------
/client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | db-fahrplan-api-client
4 | jar
5 | Deutsche Bahn Fahrplan API - Java Client
6 |
7 | org.hisrc.db-fahrplan-api
8 | db-fahrplan-api-project
9 | 1.0.1-SNAPSHOT
10 |
11 |
12 |
13 | org.apache.commons
14 | commons-lang3
15 |
16 |
17 | io.swagger
18 | swagger-annotations
19 |
20 |
21 |
22 | com.sun.jersey
23 | jersey-client
24 |
25 |
26 | com.sun.jersey.contribs
27 | jersey-multipart
28 |
29 |
30 |
42 |
43 |
44 | com.fasterxml.jackson.core
45 | jackson-core
46 |
47 |
48 | com.fasterxml.jackson.core
49 | jackson-annotations
50 |
51 |
52 | com.fasterxml.jackson.jaxrs
53 | jackson-jaxrs-json-provider
54 | ${jackson.version}
55 |
56 |
57 | com.fasterxml.jackson.core
58 | jackson-databind
59 |
60 |
61 | com.fasterxml.jackson.datatype
62 | jackson-datatype-jsr310
63 |
64 |
65 | com.fasterxml.jackson.datatype
66 | jackson-datatype-joda
67 |
68 |
69 | com.brsanthu
70 | migbase64
71 |
72 |
73 | joda-time
74 | joda-time
75 |
76 |
80 |
81 |
82 |
83 |
84 | io.swagger
85 | swagger-codegen-maven-plugin
86 | 2.1.6-SNAPSHOT
87 |
88 |
89 |
90 | generate
91 |
92 |
93 | ${basedir}/src/main/resources/db-fahrplan-api-specification.yaml
94 | java
95 |
96 |
97 |
98 |
99 |
101 |
102 | org.hisrc.dbfahrplanapi.client.model
103 | org.hisrc.dbfahrplanapi.client.api
104 | org.hisrc.dbfahrplanapi.client.invoker
105 | joda
106 |
107 |
108 |
109 |
110 |
111 |
112 | maven-antrun-plugin
113 |
114 |
115 | generate-sources
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 | run
125 |
126 |
127 |
128 |
129 |
130 | org.codehaus.mojo
131 | build-helper-maven-plugin
132 |
133 |
134 | add-source
135 | generate-sources
136 |
137 | add-source
138 |
139 |
140 |
141 | ${basedir}/target/generated-sources/swagger
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/client/src/main/java/org/hisrc/dbfahrplanapi/client/DbFahrplanApiClient.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client;
2 |
3 | import java.util.List;
4 |
5 | import org.hisrc.dbfahrplanapi.client.model.DepartureOrArrival;
6 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetail;
7 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailRef;
8 | import org.hisrc.dbfahrplanapi.client.model.StopLocation;
9 | import org.joda.time.LocalDateTime;
10 |
11 | public interface DbFahrplanApiClient {
12 |
13 | public List arrivalBoard(String stopId, LocalDateTime dateTime) throws DbFahrplanApiException;
14 |
15 | public List arrivalBoard(String stopId, LocalDateTime dateTime, String lang)
16 | throws DbFahrplanApiException;
17 |
18 | public List departureBoard(String stopId, LocalDateTime dateTime) throws DbFahrplanApiException;
19 |
20 | public List departureBoard(String stopId, LocalDateTime dateTime, String lang)
21 | throws DbFahrplanApiException;
22 |
23 | public List locationName(String input) throws DbFahrplanApiException;
24 |
25 | public List locationName(String input, String lang) throws DbFahrplanApiException;
26 |
27 | public JourneyDetail journeyDetail(JourneyDetailRef journeyDetailRef) throws DbFahrplanApiException;
28 |
29 | public JourneyDetail journeyDetail(JourneyDetailRef journeyDetailRef, String lang) throws DbFahrplanApiException;
30 | }
31 |
--------------------------------------------------------------------------------
/client/src/main/java/org/hisrc/dbfahrplanapi/client/DbFahrplanApiException.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client;
2 |
3 | import org.hisrc.dbfahrplanapi.client.invoker.ApiException;
4 |
5 | public class DbFahrplanApiException extends RuntimeException {
6 | private static final long serialVersionUID = 8301313499805392414L;
7 |
8 | public DbFahrplanApiException(String message, ApiException cause) {
9 | super(message, cause);
10 | }
11 |
12 | @Override
13 | public synchronized ApiException getCause() {
14 | return (ApiException) super.getCause();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/client/src/main/java/org/hisrc/dbfahrplanapi/client/DefaultDbFahrplanApiClient.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client;
2 |
3 | import java.io.UnsupportedEncodingException;
4 | import java.net.URLDecoder;
5 | import java.text.MessageFormat;
6 | import java.util.Collections;
7 | import java.util.List;
8 | import java.util.Objects;
9 |
10 | import org.hisrc.dbfahrplanapi.client.api.DefaultApi;
11 | import org.hisrc.dbfahrplanapi.client.invoker.ApiException;
12 | import org.hisrc.dbfahrplanapi.client.invoker.CustomizedApiClient;
13 | import org.hisrc.dbfahrplanapi.client.model.ArrivalBoardResponse;
14 | import org.hisrc.dbfahrplanapi.client.model.DepartureBoardResponse;
15 | import org.hisrc.dbfahrplanapi.client.model.DepartureOrArrival;
16 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetail;
17 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailRef;
18 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailResponse;
19 | import org.hisrc.dbfahrplanapi.client.model.LocationResponse;
20 | import org.hisrc.dbfahrplanapi.client.model.StopLocation;
21 | import org.joda.time.LocalDateTime;
22 | import org.joda.time.format.DateTimeFormat;
23 | import org.joda.time.format.DateTimeFormatter;
24 |
25 | import com.sun.jersey.api.client.ClientHandlerException;
26 |
27 | public class DefaultDbFahrplanApiClient implements DbFahrplanApiClient {
28 |
29 | private static final String FORMAT = "json";
30 | private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormat.forPattern("yyyy-MM-dd");
31 | private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormat.forPattern("HH:mm");
32 |
33 | private final String defaultLang;
34 | private final DefaultApi api;
35 |
36 | public DefaultDbFahrplanApiClient(String authKey) {
37 | this(authKey, null);
38 | }
39 |
40 | public DefaultDbFahrplanApiClient(String authKey, String defaultLang) {
41 | Objects.requireNonNull(authKey);
42 | this.defaultLang = defaultLang;
43 |
44 | this.api = new DefaultApi(new CustomizedApiClient());
45 | this.api.getApiClient().setApiKey(authKey);
46 | }
47 |
48 | @Override
49 | public List arrivalBoard(String stopId, LocalDateTime dateTime) {
50 | return this.arrivalBoard(stopId, dateTime, defaultLang);
51 | }
52 |
53 | @Override
54 | public List departureBoard(String stopId, LocalDateTime dateTime) {
55 | return this.departureBoard(stopId, dateTime, defaultLang);
56 | }
57 |
58 | @Override
59 | public List locationName(String input) {
60 | return this.locationName(input, defaultLang);
61 | }
62 |
63 | @Override
64 | public JourneyDetail journeyDetail(JourneyDetailRef journeyDetailRef) throws DbFahrplanApiException {
65 | return this.journeyDetail(journeyDetailRef, defaultLang);
66 | }
67 |
68 | @Override
69 | public List locationName(String input, String lang) throws DbFahrplanApiException {
70 | Objects.requireNonNull(input);
71 | final LocationResponse locationResponse = execute(a -> a.locationNameGet(FORMAT, input, lang));
72 | if (locationResponse != null && locationResponse.getLocationList() != null
73 | && locationResponse.getLocationList().getStopLocation() != null) {
74 | return locationResponse.getLocationList().getStopLocation();
75 | } else {
76 | return Collections.emptyList();
77 | }
78 | }
79 |
80 | @Override
81 | public List arrivalBoard(String stopId, LocalDateTime dateTime, String lang)
82 | throws DbFahrplanApiException {
83 | Objects.requireNonNull(stopId);
84 | Objects.requireNonNull(dateTime);
85 | final ArrivalBoardResponse arrivalBoardResponse = execute(a -> a.arrivalBoardGet(FORMAT, stopId,
86 | DATE_FORMATTER.print(dateTime), TIME_FORMATTER.print(dateTime), lang));
87 | if (arrivalBoardResponse != null && arrivalBoardResponse.getArrivalBoard() != null
88 | && arrivalBoardResponse.getArrivalBoard().getArrival() != null) {
89 | return arrivalBoardResponse.getArrivalBoard().getArrival();
90 | } else {
91 | return Collections.emptyList();
92 | }
93 | }
94 |
95 | @Override
96 | public List departureBoard(String stopId, LocalDateTime dateTime, String lang)
97 | throws DbFahrplanApiException {
98 | Objects.requireNonNull(stopId);
99 | Objects.requireNonNull(dateTime);
100 | final DepartureBoardResponse departureBoardResponse = execute(a -> a.departureBoardGet(FORMAT, stopId,
101 | DATE_FORMATTER.print(dateTime), TIME_FORMATTER.print(dateTime), lang));
102 | if (departureBoardResponse != null && departureBoardResponse.getDepartureBoard() != null
103 | && departureBoardResponse.getDepartureBoard().getDeparture() != null) {
104 | return departureBoardResponse.getDepartureBoard().getDeparture();
105 | } else {
106 | return Collections.emptyList();
107 | }
108 | }
109 |
110 | @Override
111 | public JourneyDetail journeyDetail(JourneyDetailRef journeyDetailRef, String lang) throws DbFahrplanApiException {
112 | Objects.requireNonNull(journeyDetailRef);
113 | final String ref = journeyDetailRef.getRef();
114 |
115 | String refPrefix = "ref=";
116 | final int refValueStartIndex = ref.indexOf(refPrefix);
117 | if (refValueStartIndex >= 0) {
118 | String refSuffix = "&";
119 | final int refValueEndIndex = ref.indexOf(refSuffix, refValueStartIndex + 1);
120 | final String refValue = refValueEndIndex >= 0
121 | ? ref.substring(refValueStartIndex + refPrefix.length(), refValueEndIndex)
122 | : ref.substring(refValueStartIndex + refPrefix.length());
123 | final String decodedRefValue;
124 | try {
125 | decodedRefValue = URLDecoder.decode(refValue, "UTF-8");
126 | } catch (UnsupportedEncodingException uex) {
127 | throw new UnsupportedOperationException(
128 | MessageFormat.format("Could not decode the URL [{0}].", refValue), uex);
129 | }
130 | final JourneyDetailResponse journeyDetailResponse = execute(
131 | a -> a.journeyDetailGet(FORMAT, decodedRefValue, lang));
132 | if (journeyDetailResponse != null) {
133 | return journeyDetailResponse.getJourneyDetail();
134 | } else {
135 | return null;
136 | }
137 | } else {
138 | throw new DbFahrplanApiException("Could not read the ref parameter.", new ApiException(
139 | MessageFormat.format("JourneyDetailRef [{0}] does not seem to contain the parameter [ref].", ref)));
140 | }
141 | }
142 |
143 | private T execute(ApiFunction operation) {
144 | try {
145 | return operation.apply(this.api);
146 | } catch (ApiException apiex) {
147 | throw new DbFahrplanApiException("Error executing the API operation.", apiex);
148 | } catch (ClientHandlerException chex1) {
149 | throw new DbFahrplanApiException("Error executing the API operation.", new ApiException(chex1));
150 | }
151 | }
152 |
153 | @FunctionalInterface
154 | private interface ApiFunction {
155 | public R apply(T base) throws ApiException;
156 | }
157 |
158 | }
159 |
--------------------------------------------------------------------------------
/client/src/main/java/org/hisrc/dbfahrplanapi/client/invoker/CustomizedApiClient.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client.invoker;
2 |
3 | import com.fasterxml.jackson.databind.DeserializationFeature;
4 |
5 | public class CustomizedApiClient extends ApiClient {
6 |
7 | public CustomizedApiClient() {
8 | this.getObjectMapper().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
9 | }
10 |
11 | }
--------------------------------------------------------------------------------
/client/src/main/resources/db-fahrplan-api-specification.yaml:
--------------------------------------------------------------------------------
1 | swagger: '2.0'
2 | info:
3 | version: "1"
4 | title: DB Fahrplan API
5 | description: Deutsche Bahn Fahrplan API
6 | # termsOfService: TBD
7 | # contact:
8 | # url: TBD
9 | schemes:
10 | - http
11 | host: open-api.bahn.de
12 | basePath: /bin/rest.exe
13 | consumes:
14 | - application/x-www-form-urlencoded
15 | - application/json
16 | securityDefinitions:
17 | authKey:
18 | type: apiKey
19 | in: query
20 | name: authKey
21 |
22 | paths:
23 |
24 | /location.name:
25 | get:
26 | description: The location.name service can be used to perform a pattern matching of a user input and to retrieve a list of possible matches in the journey planner database. Possible matches might be stops/stations, points of interest and addresses.
27 | security:
28 | -
29 | authKey: []
30 | consumes:
31 | - application/json
32 | produces:
33 | - application/json
34 | parameters:
35 | -
36 | name: format
37 | description: The interface returns responses either in XML (default) or JSON format.
38 | in: query
39 | required: true
40 | type: string
41 | enum:
42 | - json
43 | -
44 | name: lang
45 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
46 | in: query
47 | required: false
48 | type: string
49 | default: en
50 | enum:
51 | - en
52 | - de
53 | - fr
54 | - da
55 | - pl
56 | - it
57 | - es
58 | - nl
59 | -
60 | name: input
61 | description: This parameter contains a string with the user input.
62 | in: query
63 | required: true
64 | type: string
65 | responses:
66 | 200:
67 | description: The result is a list of possible matches (locations) where the user might pick one entry to perform a trip request with this location as origin or destination or to ask for a departure board or arrival board of this location (stops/stations only).
68 | schema:
69 | $ref: '#/definitions/LocationResponse'
70 |
71 | /departureBoard:
72 | get:
73 | description: Retrieves the station board for the given station. This method will return the next 20 departures (or less if not existing) from a given point in time. The service can only be called for stops/stations by using according ID retrieved by the location.name method.
74 | security:
75 | -
76 | authKey: []
77 | consumes:
78 | - application/json
79 | produces:
80 | - application/json
81 | parameters:
82 | -
83 | name: format
84 | description: The interface returns responses either in XML (default) or JSON format.
85 | in: query
86 | required: true
87 | type: string
88 | enum:
89 | - json
90 | -
91 | name: lang
92 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
93 | in: query
94 | required: false
95 | type: string
96 | default: en
97 | enum:
98 | - en
99 | - de
100 | - fr
101 | - da
102 | - pl
103 | - it
104 | - es
105 | - nl
106 | -
107 | name: id
108 | description: Id of the stop/station. The service can only be called for stops/stations by using according id retrieved by the location method.
109 | in: query
110 | required: true
111 | type: string
112 | -
113 | name: date
114 | description: The date of departures.
115 | in: query
116 | required: true
117 | type: string
118 | -
119 | name: time
120 | description: The time of departures.
121 | in: query
122 | required: true
123 | type: string
124 | responses:
125 | 200:
126 | description: The next 20 departures (or less if not existing) from a given point in time.
127 | schema:
128 | $ref: '#/definitions/DepartureBoardResponse'
129 |
130 | /arrivalBoard:
131 | get:
132 | description: Retrieves the station board for the given station. This method will return the next 20 arrivals (or less if not existing) from a given point in time. The service can only be called for stops/stations by using according ID retrieved by the location.name method.
133 | security:
134 | -
135 | authKey: []
136 | consumes:
137 | - application/json
138 | produces:
139 | - application/json
140 | parameters:
141 | -
142 | name: format
143 | description: The interface returns responses either in XML (default) or JSON format.
144 | in: query
145 | required: true
146 | type: string
147 | enum:
148 | - json
149 | -
150 | name: lang
151 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
152 | in: query
153 | required: false
154 | type: string
155 | default: en
156 | enum:
157 | - en
158 | - de
159 | - fr
160 | - da
161 | - pl
162 | - it
163 | - es
164 | - nl
165 | -
166 | name: id
167 | description: Id of the stop/station. The service can only be called for stops/stations by using according id retrieved by the location method.
168 | in: query
169 | required: true
170 | type: string
171 | -
172 | name: date
173 | description: The date of arrivals.
174 | in: query
175 | required: true
176 | type: string
177 | -
178 | name: time
179 | description: The time of arrivals.
180 | in: query
181 | required: true
182 | type: string
183 | responses:
184 | 200:
185 | description: The next 20 arrivals (or less if not existing) from a given point in time.
186 | schema:
187 | $ref: '#/definitions/ArrivalBoardResponse'
188 |
189 | /journeyDetail:
190 | get:
191 | description: Delivers information about the complete route of a vehicle. This service can't be called directly but only by reference URLs in a result of a departureBoard request. It contains a list of all stops/stations of this journey including all departure and arrival times (with realtime data if available / not supported right now) and additional information like specific attributes about facilities and other texts.
192 | consumes:
193 | - application/json
194 | produces:
195 | - application/json
196 | parameters:
197 | -
198 | name: format
199 | description: The interface returns responses either in XML (default) or JSON format.
200 | in: query
201 | required: true
202 | type: string
203 | enum:
204 | - json
205 | -
206 | name: lang
207 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
208 | in: query
209 | required: false
210 | type: string
211 | default: en
212 | enum:
213 | - en
214 | - de
215 | - fr
216 | - da
217 | - pl
218 | - it
219 | - es
220 | - nl
221 | -
222 | name: ref
223 | description: Reference identifier.
224 | in: query
225 | required: true
226 | type: string
227 | responses:
228 | 200:
229 | description: List of all stops/stations of this journey including all departure and arrival times (with realtime data if available / not supported right now) and additional information like specific attributes about facilities and other texts.
230 | schema:
231 | $ref: '#/definitions/JourneyDetailResponse'
232 | definitions:
233 | LocationResponse:
234 | type: object
235 | required:
236 | - LocationList
237 | properties:
238 | LocationList:
239 | $ref: '#/definitions/LocationList'
240 | LocationList:
241 | type: object
242 | required:
243 | - StopLocation
244 | properties:
245 | StopLocation:
246 | type: array
247 | items:
248 | $ref: '#/definitions/StopLocation'
249 | StopLocation:
250 | type: object
251 | required:
252 | - name
253 | - lon
254 | - lat
255 | - id
256 | properties:
257 | id:
258 | type: string
259 | name:
260 | type: string
261 | lon:
262 | type: number
263 | format: double
264 | lat:
265 | type: number
266 | format: double
267 | DepartureBoardResponse:
268 | type: object
269 | required:
270 | - DepartureBoard
271 | properties:
272 | DepartureBoard:
273 | $ref: '#/definitions/DepartureBoard'
274 | DepartureBoard:
275 | type: object
276 | required:
277 | - Departure
278 | properties:
279 | Departure:
280 | type: array
281 | items:
282 | $ref: '#/definitions/DepartureOrArrival'
283 | ArrivalBoardResponse:
284 | type: object
285 | required:
286 | - ArrivalBoard
287 | properties:
288 | ArrivalBoard:
289 | $ref: '#/definitions/ArrivalBoard'
290 | ArrivalBoard:
291 | type: object
292 | required:
293 | - Arrival
294 | properties:
295 | Arrival:
296 | type: array
297 | items:
298 | $ref: '#/definitions/DepartureOrArrival'
299 | DepartureOrArrival:
300 | type: object
301 | required:
302 | - name
303 | - type
304 | - stopid
305 | - stop
306 | - time
307 | - date
308 | - direction
309 | - track
310 | - JourneyDetailRef
311 | properties:
312 | name:
313 | type: string
314 | type:
315 | type: string
316 | stopid:
317 | type: string
318 | stop:
319 | type: string
320 | time:
321 | $ref: '#/definitions/LocalTime'
322 | date:
323 | $ref: '#/definitions/LocalDate'
324 | direction:
325 | type: string
326 | track:
327 | type: string
328 | JourneyDetailRef:
329 | $ref: '#/definitions/JourneyDetailRef'
330 | JourneyDetailRef:
331 | type: object
332 | required:
333 | - ref
334 | properties:
335 | ref:
336 | type: string
337 | JourneyDetailResponse:
338 | type: object
339 | required:
340 | - JourneyDetail
341 | properties:
342 | JourneyDetail:
343 | $ref: '#/definitions/JourneyDetail'
344 | JourneyDetail:
345 | type: object
346 | required:
347 | - Stops
348 | - Names
349 | - Types
350 | - Operators
351 | - Notes
352 | properties:
353 | Stops:
354 | $ref: '#/definitions/Stops'
355 | Names:
356 | $ref: '#/definitions/Names'
357 | Types:
358 | $ref: '#/definitions/Types'
359 | Operators:
360 | $ref: '#/definitions/Operators'
361 | Notes:
362 | $ref: '#/definitions/Notes'
363 | Stops:
364 | type: object
365 | required:
366 | - Stop
367 | properties:
368 | Stop:
369 | type: array
370 | items:
371 | $ref: '#/definitions/Stop'
372 | Stop:
373 | type: object
374 | required:
375 | - id
376 | - name
377 | - lon
378 | - lat
379 | - routeIdx
380 | - depTime
381 | - depDate
382 | - track
383 | properties:
384 | id:
385 | type: string
386 | name:
387 | type: string
388 | lon:
389 | type: number
390 | format: double
391 | lat:
392 | type: number
393 | format: double
394 | routeIdx:
395 | type: integer
396 | format: int32
397 | depTime:
398 | $ref: '#/definitions/LocalTime'
399 | depDate:
400 | $ref: '#/definitions/LocalDate'
401 | track:
402 | type: string
403 | Names:
404 | type: object
405 | required:
406 | - Name
407 | properties:
408 | Name:
409 | type: array
410 | items:
411 | $ref: '#/definitions/Name'
412 | Name:
413 | type: object
414 | required:
415 | - name
416 | - routeIdxFrom
417 | - routeIdxTo
418 | properties:
419 | name:
420 | type: string
421 | routeIdxFrom:
422 | type: integer
423 | format: int32
424 | routeIdxTo:
425 | type: integer
426 | format: int32
427 | Types:
428 | type: object
429 | required:
430 | - Type
431 | properties:
432 | Type:
433 | type: array
434 | items:
435 | $ref: '#/definitions/Type'
436 | Type:
437 | type: object
438 | required:
439 | - type
440 | - routeIdxFrom
441 | - routeIdxTo
442 | properties:
443 | type:
444 | type: string
445 | routeIdxFrom:
446 | type: integer
447 | format: int32
448 | routeIdxTo:
449 | type: integer
450 | format: int32
451 | Operators:
452 | type: object
453 | required:
454 | - Operator
455 | properties:
456 | Operator:
457 | type: array
458 | items:
459 | $ref: '#/definitions/Operator'
460 | Operator:
461 | type: object
462 | required:
463 | - name
464 | - routeIdxFrom
465 | - routeIdxTo
466 | properties:
467 | name:
468 | type: string
469 | routeIdxFrom:
470 | type: integer
471 | format: int32
472 | routeIdxTo:
473 | type: integer
474 | format: int32
475 | Notes:
476 | type: object
477 | required:
478 | - Note
479 | properties:
480 | Note:
481 | type: array
482 | items:
483 | $ref: '#/definitions/Note'
484 | Note:
485 | type: object
486 | required:
487 | - key
488 | - priority
489 | - routeIdxFrom
490 | - routeIdxTo
491 | - $
492 | properties:
493 | key:
494 | type: string
495 | priority:
496 | type: integer
497 | format: int32
498 | routeIdxFrom:
499 | type: integer
500 | format: int32
501 | routeIdxTo:
502 | type: integer
503 | format: int32
504 | $:
505 | type: string
506 | LocalTime:
507 | type: string
508 | LocalDate:
509 | type: string
--------------------------------------------------------------------------------
/client/src/main/resources/hafasRestArrivalBoard.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | The arrival board lists up to 20 arrivals at a specific stop/station or group of stop/stations.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | If some problem occurs while creating the arrival board you can find an error code here. Note: These error codes are not suitable for end users but only for reporting purposes. Most of the errors do not indicate a system failure but data or request parameter issues.
22 |
23 |
24 |
25 |
26 |
27 | The element Arrival contains all information about a arrival like time, date, stop/station name, track, realtime time, date and track, origin, name and type of the journey. It also contains a reference to journey details.
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | The attribute name specifies the name of the arriving journey (e.g. "Bus 100").
40 |
41 |
42 |
43 |
44 | The attribute type specifies the type of the arriving journey. Valid values are IC (InterCity), LYN (Lyntog), REG (Regionaltog), S (S-Tog), TOG (other train), BUS (Bus), EXB (Express Buss), NB (Nattbus), TB (Telebus, other form of transport), F (Ferry) and M (Metro).
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Contains the name of the stop/station.
65 |
66 |
67 |
68 |
69 | Time in format HH:MM.
70 |
71 |
72 |
73 |
74 | Date in format DD.MM.YY.
75 |
76 |
77 |
78 |
79 | Track information, if available.
80 |
81 |
82 |
83 |
84 | Realtime time in format HH:MM if available.
85 |
86 |
87 |
88 |
89 | Realtime date in format DD.MM.YY, if available.
90 |
91 |
92 |
93 |
94 | Realtime track information, if available.
95 |
96 |
97 |
98 |
99 | Origin of the journey.
100 |
101 |
102 |
103 |
104 | This attribute gives information whether this journey is cancelled
105 |
106 |
107 |
108 |
109 | This attribute gives the number of messages for this journey
110 |
111 |
112 |
113 |
114 | This attribute gives the state of the current journey
115 |
116 |
117 |
118 |
119 |
120 | Reference to journey details.
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 | Contains a URL to call the ReST interface for journey details.
130 |
131 |
132 |
133 |
134 |
--------------------------------------------------------------------------------
/client/src/main/resources/hafasRestDepartureBoard.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | The departure board lists up to 20 departures at a specific stop/station or group of stop/stations.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | If some problem occurs while creating the departure board you can find an error code here. Note: These error codes are not suitable for end users but only for reporting purposes. Most of the errors do not indicate a system failure but data or request parameter issues.
23 |
24 |
25 |
26 |
27 |
28 | The element Departure contains all information about a departure like time, date, stop/station name, track, realtime time, date and track, direction, name and type of the journey. It also contains a reference to journey details.
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | The attribute name specifies the name of the departing journey (e.g. "Bus 100").
41 |
42 |
43 |
44 |
45 |
46 | The attribute type specifies the type of the departing journey. Valid values are IC (InterCity), LYN (Lyntog), REG (Regionaltog), S (S-Tog), TOG (other train), BUS (Bus), EXB (Express Buss), NB (Nattbus), TB (Telebus, other form of transport), F (Ferry) and M (Metro).
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Contains the name of the stop/station.
68 |
69 |
70 |
71 |
72 |
73 | Time in format HH:MM.
74 |
75 |
76 |
77 |
78 |
79 | Date in format DD.MM.YY.
80 |
81 |
82 |
83 |
84 |
85 | Track information, if available.
86 |
87 |
88 |
89 |
90 |
91 | Realtime time in format HH:MM if available.
92 |
93 |
94 |
95 |
96 |
97 | Realtime date in format DD.MM.YY, if available.
98 |
99 |
100 |
101 |
102 |
103 | Realtime track information, if available.
104 |
105 |
106 |
107 |
108 |
109 | Direction information.
110 |
111 |
112 |
113 |
114 |
115 | This attribute gives information whether this journey is cancelled
116 |
117 |
118 |
119 |
120 | This attribute gives the number of messages for this journey
121 |
122 |
123 |
124 |
125 | This attribute gives the name of the final stop of this journey
126 |
127 |
128 |
129 |
130 | This attribute gives the state of the current journey
131 |
132 |
133 |
134 |
135 |
136 | Reference to journey details.
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | Contains a URL to call the ReST interface for journey details.
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/client/src/main/resources/hafasRestJourneyDetail.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | The journey details contain a list of stops/stations and notes. They also contain the journeys names and types.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | List of HIM messages
21 |
22 |
23 |
24 |
25 |
26 | Single HIM message
27 |
28 |
29 |
30 |
31 |
32 | Contains the header text of a HIM message
33 |
34 |
35 |
36 |
37 | Contains the message text of a HIM message
38 |
39 |
40 |
41 |
42 | List of links for a HIM message
43 |
44 |
45 |
46 |
47 |
48 | Single link of a HIM message
49 |
50 |
51 |
52 |
53 | URL for a link
54 |
55 |
56 |
57 |
58 | Linktext for a link
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | Contains a text with change information for this journeydetail. Possible values are: CANCELLATION, DEACTIVATION, ACTIVATION and NEW
77 |
78 |
79 |
80 |
81 | Start of validity on total route.
82 |
83 |
84 |
85 |
86 | End of validity on total route.
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | The element Stop contains the name of the stop/station, the route index, the x coordinate, the y coordinate, the departure time and date, the arrival time and date, the track, the realtime departure time and date, the realtime arrival time and date and the realtime track.
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | Contains the name of the stop/station.
106 |
107 |
108 |
109 |
110 |
111 | Route index of a stop/station. Can be used as a reference of the stop/station in a journeyDetail response.
112 |
113 |
114 |
115 |
116 | The x coordinate as integer in WGS84 multiplied with 1,000,000
117 |
118 |
119 |
120 |
121 | The y coordinate as integer in WGS84 multiplied with 1,000,000
122 |
123 |
124 |
125 |
126 | Departure time in format HH:MM, if available.
127 |
128 |
129 |
130 |
131 |
132 | Departure date in format DD.MM.YY, if available.
133 |
134 |
135 |
136 |
137 |
138 | Arrival time in format HH:MM, if available.
139 |
140 |
141 |
142 |
143 |
144 | Arrival date in format DD.MM.YY, if available.
145 |
146 |
147 |
148 |
149 |
150 | Track information, if available.
151 |
152 |
153 |
154 |
155 |
156 | Realtime departure time in format HH:MM if available.
157 |
158 |
159 |
160 |
161 |
162 | Realtime departure date in format DD.MM.YY, if available.
163 |
164 |
165 |
166 |
167 |
168 | Realtime arrival time in format HH:MM if available.
169 |
170 |
171 |
172 |
173 |
174 | Realtime arrival date in format DD.MM.YY, if available.
175 |
176 |
177 |
178 |
179 |
180 | Realtime track information, if available.
181 |
182 |
183 |
184 |
185 |
186 |
187 | Contains a text with notes to be displayed for this leg.
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 | Text to be displayed.
197 |
198 |
199 |
200 |
201 | Start of validity on total route.
202 |
203 |
204 |
205 |
206 | End of validity on total route.
207 |
208 |
209 |
210 |
211 |
212 | Contains name of journey.
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | Name to be displayed.
222 |
223 |
224 |
225 |
226 | Start of validity on total route.
227 |
228 |
229 |
230 |
231 | End of validity on total route.
232 |
233 |
234 |
235 |
236 |
237 | Contains type of journey.
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 | The attribute type specifies the type of the journey. Valid values are IC (InterCity), LYN (Lyntog), REG (Regionaltog), S (S-Tog), TOG (other train), BUS (Bus), EXB (Express Buss), NB (Nattbus), TB (Telebus, other form of transport), F (Ferry) and M (Metro).
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 | Start of validity on total route.
268 |
269 |
270 |
271 |
272 | End of validity on total route.
273 |
274 |
275 |
276 |
277 |
--------------------------------------------------------------------------------
/client/src/main/resources/hafasRestLocation.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | The location list contains either named coordinates or stops/stations with name and id as a result of a location request. The data of every list entry can be used for further trip or departureBoard requests.
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | The element StopLocation specifies a stop/station in a result of a location request. It contains an output name and an id.
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Contains the output name of this stop or station
30 |
31 |
32 |
33 |
34 | The WGS84 x coordinate as integer (multiplied by 1,000,000)
35 |
36 |
37 |
38 |
39 |
40 | The WGS84 y coordinate as integer (multiplied by 1,000,000)
41 |
42 |
43 |
44 |
45 |
46 | This ID can either be used as originId or destId to perform a trip request or to call a departure board.
47 |
48 |
49 |
50 |
51 |
52 | The element CoordLocation specifies a coordinate based location in a result of a location request. It contains an output name, x-coordinate, y coordinate and a type (address or point of interest). The coordinates and the name can be used as origin or destination parameters to perform a trip request.
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | The WGS84 x coordinate as integer (multiplied by 1,000,000)
63 |
64 |
65 |
66 |
67 |
68 | The WGS84 y coordinate as integer (multiplied by 1,000,000)
69 |
70 |
71 |
72 |
73 |
74 | Contains the output name of the address or point of interest
75 |
76 |
77 |
78 |
79 | The attribute type specifies the type of location. Valid values are ADR (address) or POI (point of interest). This attribute can be used to do some sort of classification in the user interface. For later trip requests it does not have any meaning.
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/client/src/test/java/org/hisrc/dbfahrplanapi/client/api/tests/DefaultApiClientTest.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client.api.tests;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.UnsupportedEncodingException;
6 | import java.net.URLDecoder;
7 | import java.text.MessageFormat;
8 | import java.util.Properties;
9 |
10 | import org.hisrc.dbfahrplanapi.client.api.DefaultApi;
11 | import org.hisrc.dbfahrplanapi.client.invoker.ApiException;
12 | import org.hisrc.dbfahrplanapi.client.invoker.CustomizedApiClient;
13 | import org.hisrc.dbfahrplanapi.client.model.ArrivalBoardResponse;
14 | import org.hisrc.dbfahrplanapi.client.model.DepartureBoardResponse;
15 | import org.hisrc.dbfahrplanapi.client.model.DepartureOrArrival;
16 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailResponse;
17 | import org.hisrc.dbfahrplanapi.client.model.LocationResponse;
18 | import org.joda.time.LocalDate;
19 | import org.junit.Assert;
20 | import org.junit.Before;
21 | import org.junit.Test;
22 |
23 | public class DefaultApiClientTest {
24 |
25 | private static final String AUTH_KEY_PROPERTY_KEY = "authKey";
26 |
27 | private static final String DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME = "db-fahrplan-api.properties";
28 |
29 | private DefaultApi sut;
30 |
31 | @Before
32 | public void createDefaultApi() throws IOException {
33 | final Properties properties = new Properties();
34 | final InputStream is = getClass().getClassLoader()
35 | .getResourceAsStream(DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME);
36 | Assert.assertNotNull(MessageFormat.format(
37 | "Could not find the [{0}] resource. For tests, please create src/test/resources/{0} with authKey= property.",
38 | DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME));
39 | properties.load(is);
40 | final String authKey = properties.getProperty(AUTH_KEY_PROPERTY_KEY);
41 | sut = new DefaultApi(new CustomizedApiClient());
42 | sut.getApiClient().setApiKey(authKey);
43 | }
44 |
45 | @Test
46 | public void returnsLocationResponse() throws ApiException {
47 | final LocationResponse locationResponse = sut.locationNameGet("json", "frankfurt hbf", "de");
48 | Assert.assertNotNull(locationResponse);
49 | Assert.assertTrue(locationResponse.getLocationList().getStopLocation().size() > 1);
50 | }
51 |
52 | @Test
53 | public void returnsDepartureBoardResponse() throws ApiException {
54 | DepartureBoardResponse departureBoardGet = sut.departureBoardGet("json", "8000105",
55 | LocalDate.now().toString("yyyy-MM-dd"), "15:01", "en");
56 | Assert.assertTrue(departureBoardGet.getDepartureBoard().getDeparture().size() > 1);
57 | }
58 |
59 | @Test
60 | public void returnsArrivalBoardResponse() throws ApiException {
61 | ArrivalBoardResponse arrivalBoardGet = sut.arrivalBoardGet("json", "8000105",
62 | LocalDate.now().toString("yyyy-MM-dd"), "15:01", "en");
63 | Assert.assertTrue(arrivalBoardGet.getArrivalBoard().getArrival().size() > 1);
64 | }
65 |
66 | @Test
67 | public void returnsJourneyDetailResponse() throws ApiException, UnsupportedEncodingException {
68 | DepartureBoardResponse departureBoardGet = sut.departureBoardGet("json", "8000105",
69 | LocalDate.now().toString("yyyy-MM-dd"), "15:01", "en");
70 | final DepartureOrArrival departureOrArrival = departureBoardGet.getDepartureBoard().getDeparture().get(0);
71 | String ref = departureOrArrival.getJourneyDetailRef().getRef();
72 | String refValue = ref.substring(ref.indexOf("?ref=") + 5);
73 | String decodedRefvalue = URLDecoder.decode(refValue, "UTF-8");
74 | final JourneyDetailResponse journeyDetailResponse = sut.journeyDetailGet("json", decodedRefvalue, "en");
75 | Assert.assertTrue(journeyDetailResponse.getJourneyDetail().getStops().getStop().size() > 1);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/client/src/test/java/org/hisrc/dbfahrplanapi/client/model/tests/ApiClientMapperTest.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client.model.tests;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 |
6 | import org.hisrc.dbfahrplanapi.client.invoker.CustomizedApiClient;
7 | import org.hisrc.dbfahrplanapi.client.model.DepartureBoardResponse;
8 | import org.hisrc.dbfahrplanapi.client.model.DepartureOrArrival;
9 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailResponse;
10 | import org.hisrc.dbfahrplanapi.client.model.LocationResponse;
11 | import org.hisrc.dbfahrplanapi.client.model.Stop;
12 | import org.hisrc.dbfahrplanapi.client.model.StopLocation;
13 | import org.joda.time.LocalDate;
14 | import org.joda.time.LocalTime;
15 | import org.junit.Assert;
16 | import org.junit.Test;
17 |
18 | import com.fasterxml.jackson.databind.ObjectMapper;
19 |
20 | public class ApiClientMapperTest {
21 |
22 | private ObjectMapper sut = new CustomizedApiClient().getObjectMapper();
23 |
24 | @Test
25 | public void parsesDeparture() throws IOException {
26 | try (InputStream is = getClass().getResourceAsStream("departure.json")) {
27 | DepartureBoardResponse response = sut.readValue(is, DepartureBoardResponse.class);
28 | Assert.assertEquals(8, response.getDepartureBoard().getDeparture().size());
29 | final DepartureOrArrival departure = response.getDepartureBoard().getDeparture().get(0);
30 | Assert.assertEquals("RE 15306", departure.getName());
31 | Assert.assertEquals("RE", departure.getType());
32 | Assert.assertEquals("8000105", departure.getStopid());
33 | Assert.assertEquals("Frankfurt(Main)Hbf", departure.getStop());
34 | Assert.assertEquals(LocalTime.parse("15:01"), departure.getTime());
35 | Assert.assertEquals(LocalDate.parse("2016-02-22"), departure.getDate());
36 | Assert.assertEquals("Limburg(Lahn)", departure.getDirection());
37 | Assert.assertEquals("3", departure.getTrack());}
38 | }
39 | @Test
40 | public void parsesJourneyDetails() throws IOException {
41 | try (InputStream is = getClass().getResourceAsStream("journeyDetails.json")) {
42 | JourneyDetailResponse response = sut.readValue(is, JourneyDetailResponse.class);
43 | Assert.assertEquals(6, response.getJourneyDetail().getStops().getStop().size());
44 | Assert.assertEquals(1, response.getJourneyDetail().getNames().getName().size());
45 | Assert.assertEquals(1, response.getJourneyDetail().getTypes().getType().size());
46 | Assert.assertEquals(1, response.getJourneyDetail().getOperators().getOperator().size());
47 | Assert.assertEquals(1, response.getJourneyDetail().getNotes().getNote().size());
48 | final Stop stop = response.getJourneyDetail().getStops().getStop().get(0);
49 | Assert.assertEquals("Frankfurt(Main)Hbf", stop.getName());
50 | Assert.assertEquals("8000105", stop.getId());
51 | Assert.assertEquals(8.663785, stop.getLon(), 0.000001);
52 | Assert.assertEquals(50.107149, stop.getLat(), 0.000001);
53 | Assert.assertEquals(LocalTime.parse("15:02"), stop.getDepTime());
54 | Assert.assertEquals(LocalDate.parse("2016-02-22"), stop.getDepDate());
55 | Assert.assertEquals(0, stop.getRouteIdx().intValue());
56 | Assert.assertEquals("13", stop.getTrack());
57 | }
58 | }
59 | @Test
60 | public void parsesLocation() throws IOException {
61 | try (InputStream is = getClass().getResourceAsStream("location.json")) {
62 | LocationResponse response = sut.readValue(is, LocationResponse.class);
63 | Assert.assertEquals(50, response.getLocationList().getStopLocation().size());
64 | final StopLocation stopLocation = response.getLocationList().getStopLocation().get(0);
65 | Assert.assertEquals("008000105", stopLocation.getId());
66 | Assert.assertEquals("Frankfurt(Main)Hbf", stopLocation.getName());
67 | Assert.assertEquals(8.663785, stopLocation.getLon(), 0.000001);
68 | Assert.assertEquals(50.107149, stopLocation.getLat(), 0.000001);
69 | }
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/client/src/test/java/org/hisrc/dbfahrplanapi/client/tests/DbFahrplanApiClientTest.java:
--------------------------------------------------------------------------------
1 | package org.hisrc.dbfahrplanapi.client.tests;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.UnsupportedEncodingException;
6 | import java.text.MessageFormat;
7 | import java.util.List;
8 | import java.util.Properties;
9 |
10 | import org.hisrc.dbfahrplanapi.client.DbFahrplanApiClient;
11 | import org.hisrc.dbfahrplanapi.client.DefaultDbFahrplanApiClient;
12 | import org.hisrc.dbfahrplanapi.client.invoker.ApiException;
13 | import org.hisrc.dbfahrplanapi.client.model.DepartureOrArrival;
14 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetail;
15 | import org.hisrc.dbfahrplanapi.client.model.JourneyDetailRef;
16 | import org.hisrc.dbfahrplanapi.client.model.StopLocation;
17 | import org.joda.time.LocalDateTime;
18 | import org.junit.Assert;
19 | import org.junit.Before;
20 | import org.junit.Test;
21 |
22 | public class DbFahrplanApiClientTest {
23 |
24 | private static final String AUTH_KEY_PROPERTY_KEY = "authKey";
25 |
26 | private static final String DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME = "db-fahrplan-api.properties";
27 |
28 | private DbFahrplanApiClient sut;
29 |
30 | @Before
31 | public void createDefaultApi() throws IOException {
32 | final Properties properties = new Properties();
33 | final InputStream is = getClass().getClassLoader()
34 | .getResourceAsStream(DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME);
35 | Assert.assertNotNull(MessageFormat.format(
36 | "Could not find the [{0}] resource. For tests, please create src/test/resources/{0} with authKey= property.",
37 | DB_FAHRPLAN_API_PROPERTIES_RESOURCE_NAME));
38 | properties.load(is);
39 | final String authKey = properties.getProperty(AUTH_KEY_PROPERTY_KEY);
40 | sut = new DefaultDbFahrplanApiClient(authKey);
41 | }
42 |
43 | @Test
44 | public void returnsLocationResponse() throws ApiException {
45 | final List stopLocations = sut.locationName("frankfurt hbf");
46 | Assert.assertNotNull(stopLocations);
47 | Assert.assertTrue(stopLocations.size() > 1);
48 | }
49 |
50 | @Test
51 | public void returnsDepartureBoardResponse() throws ApiException {
52 | List departures = sut.departureBoard("008000105", LocalDateTime.now().withTime(15, 01, 0, 0));
53 | Assert.assertTrue(departures.size() > 1);
54 | }
55 |
56 | @Test
57 | public void returnsArrivalBoardResponse() throws ApiException {
58 | List arrivals = sut.arrivalBoard("008000105", LocalDateTime.now().withTime(15, 01, 0, 0));
59 | Assert.assertTrue(arrivals.size() > 1);
60 | }
61 |
62 | @Test
63 | public void returnsJourneyDetailResponse() throws ApiException, UnsupportedEncodingException {
64 | List arrivals = sut.arrivalBoard("008000105", LocalDateTime.now().withTime(15, 01, 0, 0));
65 | final JourneyDetailRef journeyDetailRef = arrivals.get(0).getJourneyDetailRef();
66 | final JourneyDetail journeyDetail = sut.journeyDetail(journeyDetailRef);
67 | Assert.assertNotNull(journeyDetail);
68 | }
69 | }
--------------------------------------------------------------------------------
/client/src/test/resources/.gitignore:
--------------------------------------------------------------------------------
1 | /db-fahrplan-api.properties
--------------------------------------------------------------------------------
/client/src/test/resources/README.md:
--------------------------------------------------------------------------------
1 | For testing, create a file `db-fahrplan-api.properties `:
2 |
3 | ```
4 | authKey=
5 | ```
--------------------------------------------------------------------------------
/client/src/test/resources/org/hisrc/dbfahrplanapi/client/model/tests/departure.json:
--------------------------------------------------------------------------------
1 | {
2 | "DepartureBoard":{
3 | "noNamespaceSchemaLocation":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/xsd?name=hafasRestDepartureBoard.xsd",
4 | "Departure":[{
5 | "name":"RE 15306",
6 | "type":"RE",
7 | "stopid":"8000105",
8 | "stop":"Frankfurt(Main)Hbf",
9 | "time":"15:01",
10 | "date":"2016-02-22",
11 | "direction":"Limburg(Lahn)",
12 | "track":"3",
13 | "JourneyDetailRef":{
14 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=832026%2F466506%2F733370%2F89343%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8000105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
15 | }
16 | },{
17 | "name":"ICE 1631",
18 | "type":"ICE",
19 | "stopid":"8000105",
20 | "stop":"Frankfurt(Main)Hbf",
21 | "time":"15:02",
22 | "date":"2016-02-22",
23 | "direction":"Berlin Gesundbrunnen",
24 | "track":"13",
25 | "JourneyDetailRef":{
26 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=459927%2F330279%2F329704%2F11543%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8000105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
27 | }
28 | },{
29 | "name":"S 4",
30 | "type":"S",
31 | "stopid":"8098105",
32 | "stop":"Frankfurt Hbf (tief)",
33 | "time":"15:02",
34 | "date":"2016-02-22",
35 | "direction":"Langen(Hess)",
36 | "track":"101",
37 | "JourneyDetailRef":{
38 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=208347%2F259496%2F130674%2F4127%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8098105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
39 | }
40 | },{
41 | "name":"S 9",
42 | "type":"S",
43 | "stopid":"8098105",
44 | "stop":"Frankfurt Hbf (tief)",
45 | "time":"15:02",
46 | "date":"2016-02-22",
47 | "direction":"Wiesbaden Hbf",
48 | "track":"103",
49 | "JourneyDetailRef":{
50 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=153609%2F241574%2F69160%2F16632%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8098105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
51 | }
52 | },{
53 | "name":"S 6",
54 | "type":"S",
55 | "stopid":"8098105",
56 | "stop":"Frankfurt Hbf (tief)",
57 | "time":"15:04",
58 | "date":"2016-02-22",
59 | "direction":"Friedberg(Hess)",
60 | "track":"104",
61 | "JourneyDetailRef":{
62 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=847389%2F472603%2F990992%2F213048%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8098105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
63 | }
64 | },{
65 | "name":"S 1",
66 | "type":"S",
67 | "stopid":"8098105",
68 | "stop":"Frankfurt Hbf (tief)",
69 | "time":"15:04",
70 | "date":"2016-02-22",
71 | "direction":"Rödermark-Ober Roden",
72 | "track":"102",
73 | "JourneyDetailRef":{
74 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=686085%2F419116%2F542178%2F42394%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8098105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
75 | }
76 | },{
77 | "name":"S 2",
78 | "type":"S",
79 | "stopid":"8000105",
80 | "stop":"Frankfurt(Main)Hbf",
81 | "time":"15:04",
82 | "date":"2016-02-22",
83 | "direction":"Hofheim(Taunus)",
84 | "track":"22",
85 | "JourneyDetailRef":{
86 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=163092%2F244795%2F361412%2F126342%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8000105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
87 | }
88 | },{
89 | "name":"ICE 577",
90 | "type":"ICE",
91 | "stopid":"8000105",
92 | "stop":"Frankfurt(Main)Hbf",
93 | "time":"15:05",
94 | "date":"2016-02-22",
95 | "direction":"Stuttgart Hbf",
96 | "track":"6",
97 | "JourneyDetailRef":{
98 | "ref":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/journeyDetail?ref=953499%2F496517%2F127984%2F253841%2F80%3Fdate%3D2016-02-22%26station_evaId%3D8000105%26station_type%3Ddep%26authKey%3DZUGRIFFSCODE%26lang%3Dde%26format%3Djson%26"
99 | }
100 | }]
101 | }
102 | }
--------------------------------------------------------------------------------
/client/src/test/resources/org/hisrc/dbfahrplanapi/client/model/tests/journeyDetails.json:
--------------------------------------------------------------------------------
1 | {
2 | "JourneyDetail":{
3 | "noNamespaceSchemaLocation":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/xsd?name=hafasRestJourneyDetail.xsd",
4 | "Stops":{
5 | "Stop":[{
6 | "name":"Frankfurt(Main)Hbf",
7 | "id":"8000105",
8 | "lon":"8.663785",
9 | "lat":"50.107149",
10 | "routeIdx":"0",
11 | "depTime":"15:02",
12 | "depDate":"2016-02-22",
13 | "track":"13"
14 | },{
15 | "name":"Erfurt Hbf",
16 | "id":"8010101",
17 | "lon":"11.038501",
18 | "lat":"50.972549",
19 | "routeIdx":"1",
20 | "arrTime":"17:10",
21 | "arrDate":"2016-02-22",
22 | "depTime":"17:12",
23 | "depDate":"2016-02-22",
24 | "track":"10"
25 | },{
26 | "name":"Halle(Saale)Hbf",
27 | "id":"8010159",
28 | "lon":"11.987088",
29 | "lat":"51.477509",
30 | "routeIdx":"2",
31 | "arrTime":"17:46",
32 | "arrDate":"2016-02-22",
33 | "depTime":"17:48",
34 | "depDate":"2016-02-22",
35 | "track":"6"
36 | },{
37 | "name":"Berlin Südkreuz",
38 | "id":"8011113",
39 | "lon":"13.365314",
40 | "lat":"52.475042",
41 | "routeIdx":"3",
42 | "arrTime":"18:54",
43 | "arrDate":"2016-02-22",
44 | "depTime":"18:56",
45 | "depDate":"2016-02-22",
46 | "track":"8"
47 | },{
48 | "name":"Berlin Hbf (tief)",
49 | "id":"8098160",
50 | "lon":"13.369548",
51 | "lat":"52.525589",
52 | "routeIdx":"4",
53 | "arrTime":"19:01",
54 | "arrDate":"2016-02-22",
55 | "depTime":"19:04",
56 | "depDate":"2016-02-22",
57 | "track":"6"
58 | },{
59 | "name":"Berlin Gesundbrunnen",
60 | "id":"8011102",
61 | "lon":"13.388515",
62 | "lat":"52.548961",
63 | "routeIdx":"5",
64 | "arrTime":"19:09",
65 | "arrDate":"2016-02-22",
66 | "track":"9"
67 | }]
68 | },
69 | "Names":{
70 | "Name":{
71 | "name":"ICE 1631",
72 | "routeIdxFrom":"0",
73 | "routeIdxTo":"5"
74 | }
75 | },
76 | "Types":{
77 | "Type":{
78 | "type":"ICE",
79 | "routeIdxFrom":"0",
80 | "routeIdxTo":"5"
81 | }
82 | },
83 | "Operators":{
84 | "Operator":{
85 | "name":"DPN",
86 | "routeIdxFrom":"0",
87 | "routeIdxTo":"5"
88 | }
89 | },
90 | "Notes":{
91 | "Note":{
92 | "key":"BR",
93 | "priority":"450",
94 | "routeIdxFrom":"0",
95 | "routeIdxTo":"5",
96 | "$":"Bordrestaurant"
97 | }
98 | }
99 | }
100 | }
--------------------------------------------------------------------------------
/client/src/test/resources/org/hisrc/dbfahrplanapi/client/model/tests/location.json:
--------------------------------------------------------------------------------
1 | {
2 | "LocationList":{
3 | "noNamespaceSchemaLocation":"http://DOMAINE-TOBE-DEFINED.de/bin/dev/v4/r16.04/rest.exe/v1.0/xsd?name=hafasRestLocation.xsd",
4 | "StopLocation":[{
5 | "name":"Frankfurt(Main)Hbf",
6 | "lon":"8.663785",
7 | "lat":"50.107149",
8 | "id":"008000105"
9 | },{
10 | "name":"Frankfurt(M)Flughafen",
11 | "lon":"8.570971",
12 | "lat":"50.051209",
13 | "id":"008000281"
14 | },{
15 | "name":"FRANKFURT(MAIN)",
16 | "lon":"8.663785",
17 | "lat":"50.107149",
18 | "id":"008096021"
19 | },{
20 | "name":"Frankfurt(Main)S�d",
21 | "lon":"8.686456",
22 | "lat":"50.099364",
23 | "id":"008002041"
24 | },{
25 | "name":"Frankfurt(M) Flughafen Fernbf",
26 | "lon":"8.570180",
27 | "lat":"50.053169",
28 | "id":"008070003"
29 | },{
30 | "name":"Frankfurt(Oder)",
31 | "lon":"14.546497",
32 | "lat":"52.336420",
33 | "id":"008010113"
34 | },{
35 | "name":"Frankfurt am Main Hauptbahnhof",
36 | "lon":"8.664765",
37 | "lat":"50.107598",
38 | "id":"000100010"
39 | },{
40 | "name":"Frankfurt(M) Flughafen Regionalbf",
41 | "lon":"8.571250",
42 | "lat":"50.051218",
43 | "id":"008070004"
44 | },{
45 | "name":"Frankfurt(Main)West",
46 | "lon":"8.639334",
47 | "lat":"50.118862",
48 | "id":"008002042"
49 | },{
50 | "name":"Frankfurt-Höchst",
51 | "lon":"8.542368",
52 | "lat":"50.102636",
53 | "id":"008000106"
54 | },{
55 | "name":"Frankfurt-Niederrad",
56 | "lon":"8.637078",
57 | "lat":"50.081287",
58 | "id":"008002050"
59 | },{
60 | "name":"Frankfurt-Rödelheim",
61 | "lon":"8.607027",
62 | "lat":"50.124615",
63 | "id":"008002052"
64 | },{
65 | "name":"Frankfurt(Main)Ost",
66 | "lon":"8.708641",
67 | "lat":"50.112569",
68 | "id":"008002039"
69 | },{
70 | "name":"Frankfurt-Mainkur",
71 | "lon":"8.767440",
72 | "lat":"50.134602",
73 | "id":"008002048"
74 | },{
75 | "name":"Frankfurt(Oder)-Neuberesinchen",
76 | "lon":"14.546047",
77 | "lat":"52.322325",
78 | "id":"008011557"
79 | },{
80 | "name":"Frankfurt(Oder)-Rosengarten",
81 | "lon":"14.472632",
82 | "lat":"52.337768",
83 | "id":"008011559"
84 | },{
85 | "name":"Frankfurt-Sossenheim",
86 | "lon":"8.553523",
87 | "lat":"50.115077",
88 | "id":"008002054"
89 | },{
90 | "name":"Frankfurt-Unterliederbach",
91 | "lon":"8.528021",
92 | "lat":"50.107913",
93 | "id":"008007158"
94 | },{
95 | "name":"Frankfurt am Main - Stadion",
96 | "lon":"8.633249",
97 | "lat":"50.068226",
98 | "id":"008002040"
99 | },{
100 | "name":"Frankfurt-Eschersheim",
101 | "lon":"8.655434",
102 | "lat":"50.158585",
103 | "id":"008002045"
104 | },{
105 | "name":"Frankfurt-Griesheim",
106 | "lon":"8.606398",
107 | "lat":"50.094330",
108 | "id":"008002046"
109 | },{
110 | "name":"Frankfurt-Höchst Farbwerke",
111 | "lon":"8.528731",
112 | "lat":"50.098555",
113 | "id":"008002051"
114 | },{
115 | "name":"Frankfurt-Nied",
116 | "lon":"8.570738",
117 | "lat":"50.102519",
118 | "id":"008002049"
119 | },{
120 | "name":"Frankfurt-Berkersheim",
121 | "lon":"8.697827",
122 | "lat":"50.176483",
123 | "id":"008002043"
124 | },{
125 | "name":"Frankfurt-Frankfurter Berg",
126 | "lon":"8.676550",
127 | "lat":"50.170262",
128 | "id":"008002044"
129 | },{
130 | "name":"Frankfurt-Louisa",
131 | "lon":"8.670365",
132 | "lat":"50.083957",
133 | "id":"008002047"
134 | },{
135 | "name":"Frankfurt(M)Galluswarte",
136 | "lon":"8.644719",
137 | "lat":"50.104030",
138 | "id":"008006690"
139 | },{
140 | "name":"Frankfurt(M)Hauptwache",
141 | "lon":"8.678950",
142 | "lat":"50.113927",
143 | "id":"008006692"
144 | },{
145 | "name":"Frankfurt(M)Konstablerwache",
146 | "lon":"8.687094",
147 | "lat":"50.114619",
148 | "id":"008004429"
149 | },{
150 | "name":"Frankfurt(M)Lokalbahnhof",
151 | "lon":"8.693027",
152 | "lat":"50.102169",
153 | "id":"008002038"
154 | },{
155 | "name":"Frankfurt(M)Mühlberg",
156 | "lon":"8.701504",
157 | "lat":"50.101612",
158 | "id":"008002034"
159 | },{
160 | "name":"Frankfurt(M)Ostendstraße",
161 | "lon":"8.696982",
162 | "lat":"50.112560",
163 | "id":"008002058"
164 | },{
165 | "name":"Frankfurt(M)Stresemannallee",
166 | "lon":"8.671246",
167 | "lat":"50.094438",
168 | "id":"008002059"
169 | },{
170 | "name":"Frankfurt(M)Taunusanlage",
171 | "lon":"8.668864",
172 | "lat":"50.113567",
173 | "id":"008006691"
174 | },{
175 | "name":"Frankfurt(Main)Messe",
176 | "lon":"8.643370",
177 | "lat":"50.112003",
178 | "id":"008079632"
179 | },{
180 | "name":"Frankfurt-Sindlingen",
181 | "lon":"8.512263",
182 | "lat":"50.087499",
183 | "id":"008002053"
184 | },{
185 | "name":"Frankfurt-Zeilsheim",
186 | "lon":"8.506006",
187 | "lat":"50.090123",
188 | "id":"008002055"
189 | },{
190 | "name":"Frankfurt(M) Flughafen Terminal 2",
191 | "lon":"8.588159",
192 | "lat":"50.052683",
193 | "id":"008089361"
194 | },{
195 | "name":"Frankfurt (Oder) Bahnhof",
196 | "lon":"14.545742",
197 | "lat":"52.338640",
198 | "id":"000740167"
199 | },{
200 | "name":"Frankfurt (Oder) Friedhof",
201 | "lon":"14.527368",
202 | "lat":"52.331260",
203 | "id":"000740197"
204 | },{
205 | "name":"Festhalle/Messe, Frankfurt am Main",
206 | "lon":"8.654859",
207 | "lat":"50.112183",
208 | "id":"000100210"
209 | },{
210 | "name":"Frankensteiner Platz, Frankfurt am Main",
211 | "lon":"8.692461",
212 | "lat":"50.106915",
213 | "id":"000100902"
214 | },{
215 | "name":"Frankfurter Berg S-Bahn-Station, Frankfurt am Main",
216 | "lon":"8.676433",
217 | "lat":"50.170703",
218 | "id":"000101391"
219 | },{
220 | "name":"Friedberger Platz, Frankfurt am Main",
221 | "lon":"8.691750",
222 | "lat":"50.123509",
223 | "id":"000100505"
224 | },{
225 | "name":"Frankfurt, Markt Taschendorf",
226 | "lon":"10.525685",
227 | "lat":"49.680287",
228 | "id":"000677135"
229 | },{
230 | "name":"Fechenheim Schießhöttenstraße, Frankfurt am Main",
231 | "lon":"8.773534",
232 | "lat":"50.121424",
233 | "id":"000101548"
234 | },{
235 | "name":"Flaschenburgstraße, Frankfurt am Main",
236 | "lon":"8.730880",
237 | "lat":"50.100479",
238 | "id":"000101607"
239 | },{
240 | "name":"Fischstein, Frankfurt am Main",
241 | "lon":"8.624844",
242 | "lat":"50.129280",
243 | "id":"000101223"
244 | },{
245 | "name":"Fritz-Tarnow-Straße, Frankfurt am Main",
246 | "lon":"8.668684",
247 | "lat":"50.142908",
248 | "id":"000101303"
249 | },{
250 | "name":"Friedberger Warte, Frankfurt am Main",
251 | "lon":"8.698438",
252 | "lat":"50.139636",
253 | "id":"000101430"
254 | }]
255 | }
256 | }
--------------------------------------------------------------------------------
/db-fahrplan-api-specification.yaml:
--------------------------------------------------------------------------------
1 | swagger: '2.0'
2 | info:
3 | version: "1"
4 | title: DB Fahrplan API
5 | description: Deutsche Bahn Fahrplan API
6 | # termsOfService: TBD
7 | # contact:
8 | # url: TBD
9 | schemes:
10 | - http
11 | host: open-api.bahn.de
12 | basePath: /bin/rest.exe
13 | consumes:
14 | - application/x-www-form-urlencoded
15 | - application/json
16 | securityDefinitions:
17 | authKey:
18 | type: apiKey
19 | in: query
20 | name: authKey
21 |
22 | paths:
23 |
24 | /location.name:
25 | get:
26 | description: The location.name service can be used to perform a pattern matching of a user input and to retrieve a list of possible matches in the journey planner database. Possible matches might be stops/stations, points of interest and addresses.
27 | security:
28 | -
29 | authKey: []
30 | consumes:
31 | - application/json
32 | produces:
33 | - application/json
34 | parameters:
35 | -
36 | name: format
37 | description: The interface returns responses either in XML (default) or JSON format.
38 | in: query
39 | required: true
40 | type: string
41 | enum:
42 | - json
43 | -
44 | name: lang
45 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
46 | in: query
47 | required: false
48 | type: string
49 | default: en
50 | enum:
51 | - en
52 | - de
53 | - fr
54 | - da
55 | - pl
56 | - it
57 | - es
58 | - nl
59 | -
60 | name: input
61 | description: This parameter contains a string with the user input.
62 | in: query
63 | required: true
64 | type: string
65 | responses:
66 | 200:
67 | description: The result is a list of possible matches (locations) where the user might pick one entry to perform a trip request with this location as origin or destination or to ask for a departure board or arrival board of this location (stops/stations only).
68 | schema:
69 | $ref: '#/definitions/LocationResponse'
70 |
71 | /departureBoard:
72 | get:
73 | description: Retrieves the station board for the given station. This method will return the next 20 departures (or less if not existing) from a given point in time. The service can only be called for stops/stations by using according ID retrieved by the location.name method.
74 | security:
75 | -
76 | authKey: []
77 | consumes:
78 | - application/json
79 | produces:
80 | - application/json
81 | parameters:
82 | -
83 | name: format
84 | description: The interface returns responses either in XML (default) or JSON format.
85 | in: query
86 | required: true
87 | type: string
88 | enum:
89 | - json
90 | -
91 | name: lang
92 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
93 | in: query
94 | required: false
95 | type: string
96 | default: en
97 | enum:
98 | - en
99 | - de
100 | - fr
101 | - da
102 | - pl
103 | - it
104 | - es
105 | - nl
106 | -
107 | name: id
108 | description: Id of the stop/station. The service can only be called for stops/stations by using according id retrieved by the location method.
109 | in: query
110 | required: true
111 | type: string
112 | -
113 | name: date
114 | description: The date of departures.
115 | in: query
116 | required: true
117 | type: string
118 | -
119 | name: time
120 | description: The time of departures.
121 | in: query
122 | required: true
123 | type: string
124 | responses:
125 | 200:
126 | description: The next 20 departures (or less if not existing) from a given point in time.
127 | schema:
128 | $ref: '#/definitions/DepartureBoardResponse'
129 |
130 | /arrivalBoard:
131 | get:
132 | description: Retrieves the station board for the given station. This method will return the next 20 arrivals (or less if not existing) from a given point in time. The service can only be called for stops/stations by using according ID retrieved by the location.name method.
133 | security:
134 | -
135 | authKey: []
136 | consumes:
137 | - application/json
138 | produces:
139 | - application/json
140 | parameters:
141 | -
142 | name: format
143 | description: The interface returns responses either in XML (default) or JSON format.
144 | in: query
145 | required: true
146 | type: string
147 | enum:
148 | - json
149 | -
150 | name: lang
151 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
152 | in: query
153 | required: false
154 | type: string
155 | default: en
156 | enum:
157 | - en
158 | - de
159 | - fr
160 | - da
161 | - pl
162 | - it
163 | - es
164 | - nl
165 | -
166 | name: id
167 | description: Id of the stop/station. The service can only be called for stops/stations by using according id retrieved by the location method.
168 | in: query
169 | required: true
170 | type: string
171 | -
172 | name: date
173 | description: The date of arrivals.
174 | in: query
175 | required: true
176 | type: string
177 | -
178 | name: time
179 | description: The time of arrivals.
180 | in: query
181 | required: true
182 | type: string
183 | responses:
184 | 200:
185 | description: The next 20 arrivals (or less if not existing) from a given point in time.
186 | schema:
187 | $ref: '#/definitions/ArrivalBoardResponse'
188 |
189 | /journeyDetail:
190 | get:
191 | description: Delivers information about the complete route of a vehicle. This service can't be called directly but only by reference URLs in a result of a departureBoard request. It contains a list of all stops/stations of this journey including all departure and arrival times (with realtime data if available / not supported right now) and additional information like specific attributes about facilities and other texts.
192 | consumes:
193 | - application/json
194 | produces:
195 | - application/json
196 | parameters:
197 | -
198 | name: format
199 | description: The interface returns responses either in XML (default) or JSON format.
200 | in: query
201 | required: true
202 | type: string
203 | enum:
204 | - json
205 | -
206 | name: lang
207 | description: The REST API supports multiple languages. The default language is English and it is used if no language parameter is delivered. The language code has to be lower case. The supported languages depend on the plan data of the underlying system. The chosen language only influences the returned Notes in the REST responses.
208 | in: query
209 | required: false
210 | type: string
211 | default: en
212 | enum:
213 | - en
214 | - de
215 | - fr
216 | - da
217 | - pl
218 | - it
219 | - es
220 | - nl
221 | -
222 | name: ref
223 | description: Reference identifier.
224 | in: query
225 | required: true
226 | type: string
227 | responses:
228 | 200:
229 | description: List of all stops/stations of this journey including all departure and arrival times (with realtime data if available / not supported right now) and additional information like specific attributes about facilities and other texts.
230 | schema:
231 | $ref: '#/definitions/JourneyDetailResponse'
232 | definitions:
233 | LocationResponse:
234 | type: object
235 | required:
236 | - LocationList
237 | properties:
238 | LocationList:
239 | $ref: '#/definitions/LocationList'
240 | LocationList:
241 | type: object
242 | required:
243 | - StopLocation
244 | properties:
245 | StopLocation:
246 | type: array
247 | items:
248 | $ref: '#/definitions/StopLocation'
249 | StopLocation:
250 | type: object
251 | required:
252 | - name
253 | - lon
254 | - lat
255 | - id
256 | properties:
257 | id:
258 | type: string
259 | name:
260 | type: string
261 | lon:
262 | type: number
263 | format: double
264 | lat:
265 | type: number
266 | format: double
267 | DepartureBoardResponse:
268 | type: object
269 | required:
270 | - DepartureBoard
271 | properties:
272 | DepartureBoard:
273 | $ref: '#/definitions/DepartureBoard'
274 | DepartureBoard:
275 | type: object
276 | required:
277 | - Departure
278 | properties:
279 | Departure:
280 | type: array
281 | items:
282 | $ref: '#/definitions/DepartureOrArrival'
283 | ArrivalBoardResponse:
284 | type: object
285 | required:
286 | - ArrivalBoard
287 | properties:
288 | ArrivalBoard:
289 | $ref: '#/definitions/ArrivalBoard'
290 | ArrivalBoard:
291 | type: object
292 | required:
293 | - Arrival
294 | properties:
295 | Arrival:
296 | type: array
297 | items:
298 | $ref: '#/definitions/DepartureOrArrival'
299 | DepartureOrArrival:
300 | type: object
301 | required:
302 | - name
303 | - type
304 | - stopid
305 | - stop
306 | - time
307 | - date
308 | - direction
309 | - track
310 | - JourneyDetailRef
311 | properties:
312 | name:
313 | type: string
314 | type:
315 | type: string
316 | stopid:
317 | type: string
318 | stop:
319 | type: string
320 | time:
321 | $ref: '#/definitions/LocalTime'
322 | date:
323 | $ref: '#/definitions/LocalDate'
324 | direction:
325 | type: string
326 | track:
327 | type: string
328 | JourneyDetailRef:
329 | $ref: '#/definitions/JourneyDetailRef'
330 | JourneyDetailRef:
331 | type: object
332 | required:
333 | - ref
334 | properties:
335 | ref:
336 | type: string
337 | JourneyDetailResponse:
338 | type: object
339 | required:
340 | - JourneyDetail
341 | properties:
342 | JourneyDetail:
343 | $ref: '#/definitions/JourneyDetail'
344 | JourneyDetail:
345 | type: object
346 | required:
347 | - Stops
348 | - Names
349 | - Types
350 | - Operators
351 | - Notes
352 | properties:
353 | Stops:
354 | $ref: '#/definitions/Stops'
355 | Names:
356 | $ref: '#/definitions/Names'
357 | Types:
358 | $ref: '#/definitions/Types'
359 | Operators:
360 | $ref: '#/definitions/Operators'
361 | Notes:
362 | $ref: '#/definitions/Notes'
363 | Stops:
364 | type: object
365 | required:
366 | - Stop
367 | properties:
368 | Stop:
369 | type: array
370 | items:
371 | $ref: '#/definitions/Stop'
372 | Stop:
373 | type: object
374 | required:
375 | - id
376 | - name
377 | - lon
378 | - lat
379 | - routeIdx
380 | - depTime
381 | - depDate
382 | - track
383 | properties:
384 | id:
385 | type: string
386 | name:
387 | type: string
388 | lon:
389 | type: number
390 | format: double
391 | lat:
392 | type: number
393 | format: double
394 | routeIdx:
395 | type: integer
396 | format: int32
397 | depTime:
398 | $ref: '#/definitions/LocalTime'
399 | depDate:
400 | $ref: '#/definitions/LocalDate'
401 | track:
402 | type: string
403 | Names:
404 | type: object
405 | required:
406 | - Name
407 | properties:
408 | Name:
409 | type: array
410 | items:
411 | $ref: '#/definitions/Name'
412 | Name:
413 | type: object
414 | required:
415 | - name
416 | - routeIdxFrom
417 | - routeIdxTo
418 | properties:
419 | name:
420 | type: string
421 | routeIdxFrom:
422 | type: integer
423 | format: int32
424 | routeIdxTo:
425 | type: integer
426 | format: int32
427 | Types:
428 | type: object
429 | required:
430 | - Type
431 | properties:
432 | Type:
433 | type: array
434 | items:
435 | $ref: '#/definitions/Type'
436 | Type:
437 | type: object
438 | required:
439 | - type
440 | - routeIdxFrom
441 | - routeIdxTo
442 | properties:
443 | type:
444 | type: string
445 | routeIdxFrom:
446 | type: integer
447 | format: int32
448 | routeIdxTo:
449 | type: integer
450 | format: int32
451 | Operators:
452 | type: object
453 | required:
454 | - Operator
455 | properties:
456 | Operator:
457 | type: array
458 | items:
459 | $ref: '#/definitions/Operator'
460 | Operator:
461 | type: object
462 | required:
463 | - name
464 | - routeIdxFrom
465 | - routeIdxTo
466 | properties:
467 | name:
468 | type: string
469 | routeIdxFrom:
470 | type: integer
471 | format: int32
472 | routeIdxTo:
473 | type: integer
474 | format: int32
475 | Notes:
476 | type: object
477 | required:
478 | - Note
479 | properties:
480 | Note:
481 | type: array
482 | items:
483 | $ref: '#/definitions/Note'
484 | Note:
485 | type: object
486 | required:
487 | - key
488 | - priority
489 | - routeIdxFrom
490 | - routeIdxTo
491 | - $
492 | properties:
493 | key:
494 | type: string
495 | priority:
496 | type: integer
497 | format: int32
498 | routeIdxFrom:
499 | type: integer
500 | format: int32
501 | routeIdxTo:
502 | type: integer
503 | format: int32
504 | $:
505 | type: string
506 | LocalTime:
507 | type: string
508 | LocalDate:
509 | type: string
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 | 4.0.0
3 | org.hisrc.db-fahrplan-api
4 | db-fahrplan-api-project
5 | pom
6 | 1.0.1-SNAPSHOT
7 | Deutsche Bahn Fahrplan API - Project
8 |
9 | org.sonatype.oss
10 | oss-parent
11 | 7
12 |
13 |
14 | GitHub Issues
15 | https://github.com/highsource/db-fahrplan-api/issues
16 |
17 | 2016
18 |
19 | https://github.com/highsource/db-fahrplan-api
20 | scm:git:git://github.com/highsource/db-fahrplan-api.git
21 | scm:git:git@github.com:highsource/db-fahrplan-api.git
22 |
23 |
24 | client
25 |
26 |
27 |
28 |
29 | all
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | junit
38 | junit
39 | test
40 |
41 |
42 |
43 | 1.5.4
44 | 2.4.2
45 | 2.3
46 | 4.8.1
47 | UTF-8
48 | 1.18
49 | 8.1.1
50 | 1.0.0
51 |
52 |
53 |
54 |
55 | junit
56 | junit
57 | 4.11
58 |
59 |
60 | org.apache.commons
61 | commons-lang3
62 | 3.2.1
63 |
64 |
65 | commons-io
66 | commons-io
67 | 2.4
68 |
69 |
70 |
71 | io.swagger
72 | swagger-annotations
73 | ${swagger-annotations.version}
74 |
75 |
76 |
77 | com.sun.jersey
78 | jersey-client
79 | ${jersey.version}
80 |
81 |
82 | com.sun.jersey.contribs
83 | jersey-multipart
84 | ${jersey.version}
85 |
86 |
87 |
88 | com.netflix.feign
89 | feign-core
90 | ${feign.version}
91 |
92 |
93 | com.netflix.feign
94 | feign-jackson
95 | ${feign.version}
96 |
97 |
98 | com.netflix.feign
99 | feign-slf4j
100 | ${feign.version}
101 |
102 |
103 |
104 | com.fasterxml.jackson.core
105 | jackson-core
106 | ${jackson.version}
107 |
108 |
109 | com.fasterxml.jackson.core
110 | jackson-annotations
111 | ${jackson.version}
112 |
113 |
114 | com.fasterxml.jackson.core
115 | jackson-databind
116 | ${jackson.version}
117 |
118 |
119 | com.fasterxml.jackson.jaxrs
120 | jackson-jaxrs-json-provider
121 | ${jackson.version}
122 |
123 |
124 | com.fasterxml.jackson.datatype
125 | jackson-datatype-joda
126 | ${jackson.version}
127 |
128 |
129 | com.fasterxml.jackson.datatype
130 | jackson-datatype-jsr310
131 | ${jackson.version}
132 |
133 |
134 | joda-time
135 | joda-time
136 | ${jodatime.version}
137 |
138 |
139 | com.brsanthu
140 | migbase64
141 | 2.2
142 |
143 |
144 | org.apache.oltu.oauth2
145 | org.apache.oltu.oauth2.client
146 | ${oltu.version}
147 |
148 |
149 |
150 |
151 | install
152 |
153 |
154 |
155 | maven-antrun-plugin
156 | 1.7
157 |
158 |
159 | org.codehaus.mojo
160 | build-helper-maven-plugin
161 | 1.10
162 |
163 |
164 | true
165 | maven-compiler-plugin
166 |
167 | 1.8
168 | 1.8
169 |
170 |
171 |
172 |
173 | org.eclipse.m2e
174 | lifecycle-mapping
175 | 1.0.0
176 |
177 |
178 |
179 |
180 |
181 |
182 | org.codehaus.mojo
183 |
184 |
185 | build-helper-maven-plugin
186 |
187 |
188 | [1.10,)
189 |
190 |
191 | add-source
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 | org.apache.maven.plugins
204 |
205 |
206 | maven-antrun-plugin
207 |
208 |
209 | [1.7,)
210 |
211 |
212 | run
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 | io.swagger
225 |
226 | swagger-codegen-maven-plugin
227 |
228 |
229 | [2.1.4,)
230 |
231 |
232 | generate
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
--------------------------------------------------------------------------------
/qrelease.bat:
--------------------------------------------------------------------------------
1 | setlocal
2 | echo Setting JAVA_HOME to %JAVA8_HOME%.
3 | set JAVA_HOME=%JAVA8_HOME%
4 |
5 | echo Performing a short clean build.
6 | rem pause
7 | call mvn clean install -DperformRelease
8 | echo Short clean build completed.
9 | rem pause
10 |
11 | echo Performing a full clean build.
12 | rem pause
13 | call mvn clean install -DperformRelease -Pall
14 | echo Full clean build completed.
15 | rem pause
16 |
17 | echo Setting new version to %1.
18 | rem pause
19 | call mvn versions:set -Pall -DnewVersion=%1
20 | echo Version was set to %1.
21 | rem pause
22 | call mvn versions:commit -Pall
23 | echo Version %1 committed.
24 | rem pause
25 |
26 | echo Performing a short clean build.
27 | rem pause
28 | call mvn clean install -DperformRelease
29 | echo Short clean build completed.
30 | rem pause
31 |
32 | echo Performing a full clean build.
33 | rem pause
34 | call mvn clean install -Pall -DperformRelease
35 | echo Full clean build completed.
36 | rem pause
37 |
38 | echo Checking in version %1.
39 | rem pause
40 | git commit -a -m "Version %1"
41 | echo Version %1 was checked in.
42 | rem pause
43 |
44 | echo Tagging version %1.
45 | rem pause
46 | git tag -a %1 -m "Version %1"
47 | echo Version %1 was tagged.
48 | rem pause
49 |
50 | echo Pushing version %1.
51 | rem pause
52 | git push origin master
53 | git push --tags origin master
54 | echo Version %1 was pushed.
55 | rem pause
56 |
57 | echo Performing full clean deploy.
58 | rem pause
59 | call mvn -DperformRelease -Psonatype-oss-release,all clean deploy
60 | echo Full clean deploy done.
61 | rem pause
62 |
63 | echo Setting new version to %2.
64 | rem pause
65 | call mvn versions:set -Pall -DnewVersion=%2
66 | echo Version was set to %2.
67 | rem pause
68 | call mvn versions:commit -Pall
69 | echo Version %2 was committed.
70 | rem pause
71 |
72 | echo Performing a short clean build.
73 | rem pause
74 | call mvn clean install -DperformRelease
75 | echo Short clean build completed.
76 | rem pause
77 |
78 | echo Performing a full clean build.
79 | rem pause
80 | call mvn clean install -DperformRelease -Pall
81 | echo Full clean build completed.
82 | rem pause
83 |
84 |
85 | echo Checking in version %2.
86 | rem pause
87 | git commit -a -m "Version %2"
88 | echo Version %2 was checked in.
89 | rem pause
90 |
91 | echo Pushing version %2.
92 | rem pause
93 | git push origin master
94 | git push --tags origin master
95 | echo Version %2 was pushed.
96 | rem pause
97 |
98 | endlocal
--------------------------------------------------------------------------------