From b850eb5767d646ffb8a3289af58a3ce539ba6640 Mon Sep 17 00:00:00 2001 From: Johan von Forstner Date: Thu, 12 Oct 2017 20:38:33 +0200 Subject: [PATCH] DaVinciInfoserverParser: rooms, subjects (#50) --- .idea/modules.xml | 6 +-- .idea/modules/parser/parser.iml | 47 ++++++++++--------- .idea/modules/sample/sample.iml | 43 +++++++++-------- .../modules/substitution-schedule-parser.iml | 5 +- .../parser/DaVinciInfoserverParser.java | 14 ++++-- 5 files changed, 66 insertions(+), 49 deletions(-) diff --git a/.idea/modules.xml b/.idea/modules.xml index 97afdca5..b34a36b7 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,11 +3,11 @@ - + - - + + diff --git a/.idea/modules/parser/parser.iml b/.idea/modules/parser/parser.iml index cb78ab83..0fefde14 100644 --- a/.idea/modules/parser/parser.iml +++ b/.idea/modules/parser/parser.iml @@ -1,8 +1,8 @@ - + - - + + @@ -11,28 +11,33 @@ + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/sample/sample.iml b/.idea/modules/sample/sample.iml index ea314901..b64c0bd2 100644 --- a/.idea/modules/sample/sample.iml +++ b/.idea/modules/sample/sample.iml @@ -1,8 +1,8 @@ - - + + @@ -11,27 +11,32 @@ + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/substitution-schedule-parser.iml b/.idea/modules/substitution-schedule-parser.iml index dd6e37ef..f268a10b 100644 --- a/.idea/modules/substitution-schedule-parser.iml +++ b/.idea/modules/substitution-schedule-parser.iml @@ -1,12 +1,13 @@ - - + + + diff --git a/parser/src/main/java/me/vertretungsplan/parser/DaVinciInfoserverParser.java b/parser/src/main/java/me/vertretungsplan/parser/DaVinciInfoserverParser.java index 61ffced8..e3c44502 100644 --- a/parser/src/main/java/me/vertretungsplan/parser/DaVinciInfoserverParser.java +++ b/parser/src/main/java/me/vertretungsplan/parser/DaVinciInfoserverParser.java @@ -15,6 +15,7 @@ import me.vertretungsplan.objects.SubstitutionScheduleDay; import me.vertretungsplan.objects.credential.UserPasswordCredential; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.http.client.HttpResponseException; @@ -132,10 +133,15 @@ private static SubstitutionSchedule parseDaVinciJson(JSONObject json, Substituti timeFmt.parseLocalTime(lesson.getString("startTime")), timeFmt.parseLocalTime(lesson.getString("endTime")))); - if (changes.has("lessonTitle")) { - substitution.setSubject(changes.getString("lessonTitle")); - } else if (lesson.has("courseTitle")) { - substitution.setSubject(lesson.getString("courseTitle")); + substitution.setPreviousSubject(changes.optString("subjectCode", null)); + substitution.setSubject(changes.optString("newSubjectCode", null)); + + if (lesson.has("roomCodes")) { + substitution.setRoom(StringUtils.join(toStringList(lesson.getJSONArray("roomCodes")), ", ")); + } + if (changes.has("absentRoomCodes")) { + substitution.setPreviousRoom( + StringUtils.join(toStringList(changes.getJSONArray("absentRoomCodes")), ", ")); } substitution.setType(changes.optString("caption", "Vertretung"));