vertretungsplanme/substitution-schedule-parser

Add support for LegionBoard

Closed this issue · 3 comments

LegionBoard has a central REST API managing the changes.

Before support can be added, #1 likely has to be solved. As a workaround, perhaps the teachers can be parsed as "courses".

Yes, using that workaround the app would then display the list of teachers in the "classes" dropdown so that the schedule is filtered by teacher.

Finally, I solved #1, so the workaround is no longer needed.

But as long as the main client does not support it, no school will be able to use it. Keep in mind that courses can be NULL, so there will be changes that are only linked to a teacher (And maybe even not this in the future).

@johan12345 I tried creating a parser and therefore looked at the others but I have no idea how to implement this. Do you can show me any kind of tutorial, docu or example parser that could be useful to me?

Nice that you solved #1 :)
When the course is null, you can maybe assign the course to a class with an empty name, which would then still make it display in the app.

The basic process is creating a class LegionBoardParser in the me.vertretungsplan.parser package that extends the BaseParser class and implements the getSubstitutionSchedule(), getAllClasses() and getAllTeachers() methods. Things like the ID of the school can be stored in the SubstitutionScheduleData object that is supplied to the parser (and its getData() JSON configuration).

You also need to modify this method so that it can create instances of your new parser.

You can then test your new parser using the sample project (gradlew sample:run from the command line or an IDE such as IntelliJ IDEA), where you need to modify the data.setApi and data.setData calls.

Nearly all current parsers do HTML parsing using the JSoup library. In your case, you need to parse JSON instead, for example using the JSONObject class from the org.json library already included in the project. Anyway, the SVPlanParser implementation may be a good place to start looking at, as it is not that complicated (much simpler than the Untis parsers, for example).

I am currently in the process of adding and updating Javadocs (#1), which should make it easier to understand how the parsers and the data structure work. I already added a bunch in release 1.0.0-beta5. In a few hours (when the release is available on Maven Central), the newest version should hopefully also be visible in HTML form on javadoc.io. Alternatively, you can generate the HTML javadoc using gradlew parser:javadoc, which will put the files in the parser/build/docs/javadoc folder.