You are currently browsing the code.timst() posts tagged: XML


Project: EDT Watcher

EDT Watcher (a rather nonsensical working name, “EDT” standing for “Emploi du Temps”, a timetable) is a Java library and an unfinished Android app designed to access the timetables of my home university of Nantes in a more user-friendly manner.

 

Nantes uses a web-based timetable system by Celcat for almost every department (engineering, humanities, medical school, etc). Those timetable are comprised of a large (~ 7000 lines for my former class, though we were not the busiest one) XML file detailing the lessons and events of the whole year (although it starts out empty and is then edited throughout the year as lessons are scheduled), and a bit of HTML/CSS and Javascript to make it easier to browse. Quite simple, and fine for most use cases (eg., looking at your next lessons or visualizing your week workload). However, it lacked some advanced features, and more importantly, didn’t display on mobile phones, at least not android phones.

So I started working on a small Java program to retrieve the XML file, parse it, and store the data in appropriate beans so it can be used later. Nearly the whole university is using Celcat’s system, which is a huge advantage: I start by regexin’ this page to get every department’s timetable’s sub-site’s url, and then I go to the department’s site’s group index (typically the url, + “/gindex.html”, for instance this is the group list for my department), and, if it’s not password protected, I can access the groups’ timetables. Now I can easily get the XML file for a selected group and process it.

After that, the group’s data is stored inside a Timetable object, containing an array of 52 Week objects, themselves containing an EnumMap mapping weekdays to Day objects, which hold the lessons in an ArrayList. These lessons comprises a list of teachers, rooms and modules (collectively grouped in a Resource class), a start and end times, and an ascending link to their Day.

I have to admit that it is not the greatest architecture I have ever designed, and it might probably be easier to do away with the Week and Weekdays abstraction and just list the days with their lessons in a collection, but it allow to easily perform operations on a week, and it’s the easiest way to map to the original XML files, which don’t mention days, but use weekdays and week numbers instead. Well, not even week numbers, but a 52-chars-long string with either “N” or “Y” symbolizing the position of the week in the year. Weird.

All in all, the original material seems to be of dubious quality, with esoteric formatting and a lot of redundant information, but I tried to do my best. Also, there was a lot of date and time stuff and the Java native tools in this category are… a bit lacking, so I used the popular Joda Time library instead, and it was a huge improvement.

Once I finished the whole parsing thing I added a command-line interface and a Google Agenda exporter, and then I started to work on the Android app, and, well, that’s where I stalled. I did a welcome screen, two sets of list to browse through departments and then groups, and a screen indicating the next lesson, its location and data (teachers, start and end time…)

It was actually pretty useful, and I used it often throughout the year to find my room without having to walk through half the campus to read the only timetable displayed in a corridor, but it lacks advanced features that I wanted to implement, such as a week / month timetable, statistics, and maybe an alarm clock based on your actual timetable.

 

As I said elsewhere, I’ll be leaving Nantes University soon, so I’m unsure about releasing it because it would means that I might get tangled up in support mails and possibly legal issues with the University and/or Celcat. However I still want to work on it, and it would be a shame to let it go to waste, since unlike most of my other projects, this one has real, demonstrated use cases. I’ll think about working on it during my last months here, and either release it in a user-friendly form if I think I can handle the support or find a successor / publish the source code on github before leaving. What do you think ?