Marc Rufer 20 Jul 2015 swissunihockey sports Java ical4j PDFBox
On the new website of swissunihockey there is no possibility to get an overview of all games of a team represented on one page. Based on that I decided to write an application that allows to generate a PDF document displaying the game schedule of a team.
First I had to study the swissunihockey API v2. The fact that the swissunihockey API is not designed RESTful made the challenge a bit more difficult. For example getting a club or a team by id
is not possible, so I had to provide some workarounds to solve these problems (i.e. static map in service that holds the mappings between id
and name
for every club).
To get a proper formatted game schedule of a specific team I decided to consume the game schedule in ical format (/calendar
endpoint). I started implementing the API client that consumes the swissunihockey API v2 and serves the data in the desired format. The ical data from the /calendar
endpoint will be transformed into a Calendar object provided by the ical4j library.
After finishing the API client I continued with the PDFGenerator, which is responsible to process the Calendar data and write it to a new PDF document. The PDF files are generated with Apache PDFBox. Before implementing the frontend I had to implement a service that gets data from the API client and creates the PDF document and a controller exposing an endpoint to consume the generated PDF document.
The frontend is built with Ionic, an AngularJS based front-end SDK. Because direct requests to the swissunihockey API from the javascript are not allowed (CORS) I set up a zuul proxy that proxies all requests to the swissunihockey API.
The application I wrote is a spring boot application using the following libraries:
The application can be visited here
The source code of the application is freely available on GitHub