Marc Rufer bio photo

Marc Rufer

Software engineer
@d-fens GmbH

Twitter Google+ LinkedIn Github Stackoverflow
RSS Feed

Swissunihockey game schedule PDF generator

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.

Solution

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.

Conclusion

The application I wrote is a spring boot application using the following libraries:

  • Ionic (Frotend library)
  • spring-cloud-starter-zuul (For enabling CORS)
  • ical4j (For processing ical data)
  • PDFBox (For PDF creation)

The application can be visited here

The source code of the application is freely available on GitHub

comments powered by Disqus

Posts

HOWTO Access Azure File Share in PowerShell Script executed by a Scheduled Task BUG "Task Scheduler service is not available" Error, if specifying Network Connection Condition HOWTO Sync OneDrive on Server even if Windows User not logged in HOWTO Access Microsoft Access Database with PowerShell Get NetworkCredential from PSCredential splits Username into Username and Domain HOWTO Create LocalDB File (.mdf) manually in Visual Studio 2015 HOWTO Set Cookie Header on DefaultRequestHeaders of HttpClient HOWTO Set up PowerShell Remote Session Configuration HOWTO Analyze PowerShell Scripts with PSScriptAnalyzer HOWTO Sign PDF with SuisseID NoBrainer PUT/PATCH/MERGE with OData Service Client Apply Commit from one Repository to another GitHub Repository creation with PowerShell HOWTO Sign PowerShell Script with SuisseID Swissunihockey game schedule PDF generator HOWTO Maven Release on JetBrains TeamCity Limitations when running Activiti in H2 Embedded Mode HOWTO Pylint Integration in IntelliJ 14 HOWTO Install Windows 10 IoT Core on Raspberry PI 2 from a VM First steps with Dropwizard Allman code style for IntelliJ First steps with Flyway IntelliJ - Setup custom inspection profiles Configuration properties meta-data support in IntelliJ AMQP Integration with spring integration OCA Java SE 7 Programmer I Certification Guide Swissunihockey key matcher Swisscom SMS-API-Client Some hints concerning logging with Log4j IFTTT A brilliant service Run deltacloud on a VirtualBox-VM Project specific maven settings in IntelliJ AngularJS Javascript for beginners Liferay in Action