forked from github/wulkanowy-mirror
[API] Remove duplicated POJOs (#53)
This commit is contained in:
parent
79bdbbbb16
commit
4c7c2a1101
@ -9,6 +9,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.SnP;
|
||||
import io.github.wulkanowy.api.generic.Month;
|
||||
import io.github.wulkanowy.api.generic.Subject;
|
||||
|
||||
public class AttendanceStatistics {
|
||||
|
||||
|
@ -8,6 +8,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.SnP;
|
||||
import io.github.wulkanowy.api.generic.Day;
|
||||
import io.github.wulkanowy.api.generic.Lesson;
|
||||
import io.github.wulkanowy.api.generic.Week;
|
||||
|
||||
public class AttendanceTable {
|
||||
|
||||
@ -19,11 +22,11 @@ public class AttendanceTable {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getWeekTable() throws IOException {
|
||||
public Week<Day> getWeekTable() throws IOException {
|
||||
return getWeekTable("");
|
||||
}
|
||||
|
||||
public Week getWeekTable(String tick) throws IOException {
|
||||
public Week<Day> getWeekTable(String tick) throws IOException {
|
||||
Element table = snp.getSnPPageDocument(attendancePageUrl + tick)
|
||||
.select(".mainContainer .presentData").first();
|
||||
|
||||
@ -49,7 +52,7 @@ public class AttendanceTable {
|
||||
|
||||
String[] dayDescription = headerCells.get(1).html().split("<br>");
|
||||
|
||||
return new Week()
|
||||
return new Week<Day>()
|
||||
.setStartDayDate(dayDescription[1])
|
||||
.setDays(days);
|
||||
}
|
||||
@ -58,7 +61,7 @@ public class AttendanceTable {
|
||||
Lesson lesson = new Lesson();
|
||||
lesson.setSubject(cell.select("span").text());
|
||||
|
||||
if (Lesson.CLASS_NOT_EXIST.equals(cell.attr("class"))) {
|
||||
if (LessonTypes.CLASS_NOT_EXIST.equals(cell.attr("class"))) {
|
||||
lesson.setNotExist(true);
|
||||
lesson.setEmpty(true);
|
||||
|
||||
@ -66,25 +69,25 @@ public class AttendanceTable {
|
||||
}
|
||||
|
||||
switch (cell.select("div").attr("class")) {
|
||||
case Lesson.CLASS_PRESENCE:
|
||||
case LessonTypes.CLASS_PRESENCE:
|
||||
lesson.setPresence(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_UNEXCUSED:
|
||||
case LessonTypes.CLASS_ABSENCE_UNEXCUSED:
|
||||
lesson.setAbsenceUnexcused(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_EXCUSED:
|
||||
case LessonTypes.CLASS_ABSENCE_EXCUSED:
|
||||
lesson.setAbsenceExcused(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_FOR_SCHOOL_REASONS:
|
||||
case LessonTypes.CLASS_ABSENCE_FOR_SCHOOL_REASONS:
|
||||
lesson.setAbsenceForSchoolReasons(true);
|
||||
break;
|
||||
case Lesson.CLASS_UNEXCUSED_LATENESS:
|
||||
case LessonTypes.CLASS_UNEXCUSED_LATENESS:
|
||||
lesson.setUnexcusedLateness(true);
|
||||
break;
|
||||
case Lesson.CLASS_EXCUSED_LATENESS:
|
||||
case LessonTypes.CLASS_EXCUSED_LATENESS:
|
||||
lesson.setExcusedLateness(true);
|
||||
break;
|
||||
case Lesson.CLASS_EXEMPTION:
|
||||
case LessonTypes.CLASS_EXEMPTION:
|
||||
lesson.setExemption(true);
|
||||
break;
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Day {
|
||||
|
||||
private List<Lesson> lessons = new ArrayList<>();
|
||||
|
||||
private String date = "";
|
||||
|
||||
public Lesson getLesson(int index) {
|
||||
return lessons.get(index);
|
||||
}
|
||||
|
||||
public List<Lesson> getLessons() {
|
||||
return lessons;
|
||||
}
|
||||
|
||||
public Day setLesson(Lesson lesson) {
|
||||
this.lessons.add(lesson);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Day setDate(String date) {
|
||||
this.date = date;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
public class Lesson {
|
||||
|
||||
protected static final String CLASS_NOT_EXIST = "x-sp-nieobecny-w-oddziale";
|
||||
|
||||
protected static final String CLASS_PRESENCE = "x-obecnosc";
|
||||
|
||||
protected static final String CLASS_ABSENCE_UNEXCUSED = "x-nieobecnosc-nieuspr";
|
||||
|
||||
protected static final String CLASS_ABSENCE_EXCUSED = "x-nieobecnosc-uspr";
|
||||
|
||||
protected static final String CLASS_ABSENCE_FOR_SCHOOL_REASONS = "x-nieobecnosc-przycz-szkol";
|
||||
|
||||
protected static final String CLASS_UNEXCUSED_LATENESS = "x-sp-nieusprawiedliwione";
|
||||
|
||||
protected static final String CLASS_EXCUSED_LATENESS = "x-sp-spr";
|
||||
|
||||
protected static final String CLASS_EXEMPTION = "x-sp-zwolnienie";
|
||||
|
||||
private String subject = "";
|
||||
|
||||
private boolean isNotExist = false;
|
||||
|
||||
private boolean isPresence = false;
|
||||
|
||||
private boolean isAbsenceUnexcused = false;
|
||||
|
||||
private boolean isAbsenceExcused = false;
|
||||
|
||||
private boolean isUnexcusedLateness = false;
|
||||
|
||||
private boolean isAbsenceForSchoolReasons = false;
|
||||
|
||||
private boolean isExcusedLateness = false;
|
||||
|
||||
private boolean isExemption = false;
|
||||
|
||||
private boolean isEmpty = false;
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public boolean isNotExist() {
|
||||
return isNotExist;
|
||||
}
|
||||
|
||||
public void setNotExist(boolean notExist) {
|
||||
isNotExist = notExist;
|
||||
}
|
||||
|
||||
public boolean isPresence() {
|
||||
return isPresence;
|
||||
}
|
||||
|
||||
public void setPresence(boolean presence) {
|
||||
isPresence = presence;
|
||||
}
|
||||
|
||||
public boolean isAbsenceUnexcused() {
|
||||
return isAbsenceUnexcused;
|
||||
}
|
||||
|
||||
public void setAbsenceUnexcused(boolean absenceUnexcused) {
|
||||
isAbsenceUnexcused = absenceUnexcused;
|
||||
}
|
||||
|
||||
public boolean isAbsenceExcused() {
|
||||
return isAbsenceExcused;
|
||||
}
|
||||
|
||||
public void setAbsenceExcused(boolean absenceExcused) {
|
||||
isAbsenceExcused = absenceExcused;
|
||||
}
|
||||
|
||||
public boolean isUnexcusedLateness() {
|
||||
return isUnexcusedLateness;
|
||||
}
|
||||
|
||||
public void setUnexcusedLateness(boolean unexcusedLateness) {
|
||||
isUnexcusedLateness = unexcusedLateness;
|
||||
}
|
||||
|
||||
public boolean isAbsenceForSchoolReasons() {
|
||||
return isAbsenceForSchoolReasons;
|
||||
}
|
||||
|
||||
public void setAbsenceForSchoolReasons(boolean absenceForSchoolReasons) {
|
||||
isAbsenceForSchoolReasons = absenceForSchoolReasons;
|
||||
}
|
||||
|
||||
public boolean isExcusedLateness() {
|
||||
return isExcusedLateness;
|
||||
}
|
||||
|
||||
public void setExcusedLateness(boolean excusedLateness) {
|
||||
isExcusedLateness = excusedLateness;
|
||||
}
|
||||
|
||||
public boolean isExemption() {
|
||||
return isExemption;
|
||||
}
|
||||
|
||||
public void setExemption(boolean exemption) {
|
||||
isExemption = exemption;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
public void setEmpty(boolean empty) {
|
||||
isEmpty = empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
class LessonTypes {
|
||||
|
||||
static final String CLASS_NOT_EXIST = "x-sp-nieobecny-w-oddziale";
|
||||
|
||||
static final String CLASS_PRESENCE = "x-obecnosc";
|
||||
|
||||
static final String CLASS_ABSENCE_UNEXCUSED = "x-nieobecnosc-nieuspr";
|
||||
|
||||
static final String CLASS_ABSENCE_EXCUSED = "x-nieobecnosc-uspr";
|
||||
|
||||
static final String CLASS_ABSENCE_FOR_SCHOOL_REASONS = "x-nieobecnosc-przycz-szkol";
|
||||
|
||||
static final String CLASS_UNEXCUSED_LATENESS = "x-sp-nieusprawiedliwione";
|
||||
|
||||
static final String CLASS_EXCUSED_LATENESS = "x-sp-spr";
|
||||
|
||||
static final String CLASS_EXEMPTION = "x-sp-zwolnienie";
|
||||
|
||||
private LessonTypes() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
@ -3,6 +3,8 @@ package io.github.wulkanowy.api.attendance;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.generic.Month;
|
||||
|
||||
public class Type {
|
||||
|
||||
private String name = "";
|
||||
|
@ -1,33 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Week {
|
||||
|
||||
private List<Day> days = new ArrayList<>();
|
||||
|
||||
private String startDayDate = "";
|
||||
|
||||
public Day getDay(int index) {
|
||||
return days.get(index);
|
||||
}
|
||||
|
||||
public List<Day> getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
public Week setDays(List<Day> days) {
|
||||
this.days = days;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartDayDate() {
|
||||
return startDayDate;
|
||||
}
|
||||
|
||||
public Week setStartDayDate(String startDayDate) {
|
||||
this.startDayDate = startDayDate;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -3,27 +3,17 @@ package io.github.wulkanowy.api.exams;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Day {
|
||||
import io.github.wulkanowy.api.generic.Day;
|
||||
|
||||
public class ExamDay extends Day {
|
||||
|
||||
private List<Exam> examList = new ArrayList<>();
|
||||
|
||||
private String date = "";
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Day setDate(String date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Exam> getExamList() {
|
||||
return examList;
|
||||
}
|
||||
|
||||
public Day addExam(Exam exam) {
|
||||
public void addExam(Exam exam) {
|
||||
this.examList.add(exam);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.SnP;
|
||||
import io.github.wulkanowy.api.generic.Week;
|
||||
|
||||
public class ExamsWeek {
|
||||
|
||||
@ -20,18 +21,18 @@ public class ExamsWeek {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getCurrent() throws IOException {
|
||||
public Week<ExamDay> getCurrent() throws IOException {
|
||||
return getWeek("", true);
|
||||
}
|
||||
|
||||
public Week getWeek(String tick, final boolean onlyNotEmpty) throws IOException {
|
||||
public Week<ExamDay> getWeek(String tick, final boolean onlyNotEmpty) throws IOException {
|
||||
Document examsPage = snp.getSnPPageDocument(EXAMS_PAGE_URL + tick);
|
||||
Elements examsDays = examsPage.select(".mainContainer > div:not(.navigation)");
|
||||
|
||||
List<Day> days = new ArrayList<>();
|
||||
List<ExamDay> days = new ArrayList<>();
|
||||
|
||||
for (Element item : examsDays) {
|
||||
Day day = new Day();
|
||||
ExamDay day = new ExamDay();
|
||||
Element dayHeading = item.select("h2").first();
|
||||
|
||||
if (null == dayHeading && onlyNotEmpty) {
|
||||
@ -39,7 +40,7 @@ public class ExamsWeek {
|
||||
}
|
||||
|
||||
if (null != dayHeading) {
|
||||
day = new Day().setDate(dayHeading.text().split(", ")[1]);
|
||||
day.setDate(dayHeading.text().split(", ")[1]);
|
||||
}
|
||||
|
||||
Elements exams = item.select("article");
|
||||
@ -56,10 +57,8 @@ public class ExamsWeek {
|
||||
days.add(day);
|
||||
}
|
||||
|
||||
Week week = new Week();
|
||||
week.setStartDate(examsDays.select("h2").first().text().split(" ")[1]);
|
||||
week.setDayList(days);
|
||||
|
||||
return week;
|
||||
return new Week<ExamDay>()
|
||||
.setStartDayDate(examsDays.select("h2").first().text().split(" ")[1])
|
||||
.setDays(days);
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +0,0 @@
|
||||
package io.github.wulkanowy.api.exams;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Week {
|
||||
|
||||
private List<Day> dayList = new ArrayList<>();
|
||||
|
||||
private String startDate = "";
|
||||
|
||||
public List<Day> getDayList() {
|
||||
return dayList;
|
||||
}
|
||||
|
||||
public Week setDayList(List<Day> dayList) {
|
||||
this.dayList = dayList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(String startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
package io.github.wulkanowy.api.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -7,7 +7,7 @@ public class Day {
|
||||
|
||||
private List<Lesson> lessons = new ArrayList<>();
|
||||
|
||||
private String date = "";
|
||||
protected String date = "";
|
||||
|
||||
private String dayName = "";
|
||||
|
||||
@ -41,26 +41,23 @@ public class Day {
|
||||
return dayName;
|
||||
}
|
||||
|
||||
public Day setDayName(String dayName) {
|
||||
public void setDayName(String dayName) {
|
||||
this.dayName = dayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFreeDay() {
|
||||
return isFreeDay;
|
||||
}
|
||||
|
||||
public Day setFreeDay(boolean freeDay) {
|
||||
public void setFreeDay(boolean freeDay) {
|
||||
isFreeDay = freeDay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFreeDayName() {
|
||||
return freeDayName;
|
||||
}
|
||||
|
||||
public Day setFreeDayName(String freeDayName) {
|
||||
public void setFreeDayName(String freeDayName) {
|
||||
this.freeDayName = freeDayName;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,15 +1,7 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
package io.github.wulkanowy.api.generic;
|
||||
|
||||
public class Lesson {
|
||||
|
||||
public static final String CLASS_PLANNING = "x-treelabel-ppl";
|
||||
|
||||
public static final String CLASS_REALIZED = "x-treelabel-rlz";
|
||||
|
||||
public static final String CLASS_MOVED_OR_CANCELED = "x-treelabel-inv";
|
||||
|
||||
public static final String CLASS_NEW_MOVED_IN_OR_CHANGED = "x-treelabel-zas";
|
||||
|
||||
private String number = "";
|
||||
|
||||
private String subject = "";
|
||||
@ -40,13 +32,28 @@ public class Lesson {
|
||||
|
||||
private boolean isNewMovedInOrChanged = false;
|
||||
|
||||
private boolean isNotExist = false;
|
||||
|
||||
private boolean isPresence = false;
|
||||
|
||||
private boolean isAbsenceUnexcused = false;
|
||||
|
||||
private boolean isAbsenceExcused = false;
|
||||
|
||||
private boolean isUnexcusedLateness = false;
|
||||
|
||||
private boolean isAbsenceForSchoolReasons = false;
|
||||
|
||||
private boolean isExcusedLateness = false;
|
||||
|
||||
private boolean isExemption = false;
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public Lesson setNumber(String number) {
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
@ -89,27 +96,24 @@ public class Lesson {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public Lesson setGroupName(String groupName) {
|
||||
public void setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Lesson setStartTime(String startTime) {
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public Lesson setEndTime(String endTime) {
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
@ -134,44 +138,103 @@ public class Lesson {
|
||||
return isDivisionIntoGroups;
|
||||
}
|
||||
|
||||
public Lesson setDivisionIntoGroups(boolean divisionIntoGroups) {
|
||||
public void setDivisionIntoGroups(boolean divisionIntoGroups) {
|
||||
isDivisionIntoGroups = divisionIntoGroups;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPlanning() {
|
||||
return isPlanning;
|
||||
}
|
||||
|
||||
public Lesson setPlanning(boolean planning) {
|
||||
public void setPlanning(boolean planning) {
|
||||
isPlanning = planning;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isRealized() {
|
||||
return isRealized;
|
||||
}
|
||||
|
||||
public Lesson setRealized(boolean realized) {
|
||||
public void setRealized(boolean realized) {
|
||||
isRealized = realized;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMovedOrCanceled() {
|
||||
return isMovedOrCanceled;
|
||||
}
|
||||
|
||||
public Lesson setMovedOrCanceled(boolean movedOrCanceled) {
|
||||
public void setMovedOrCanceled(boolean movedOrCanceled) {
|
||||
isMovedOrCanceled = movedOrCanceled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNewMovedInOrChanged() {
|
||||
return isNewMovedInOrChanged;
|
||||
}
|
||||
|
||||
public Lesson setNewMovedInOrChanged(boolean newMovedInOrChanged) {
|
||||
public void setNewMovedInOrChanged(boolean newMovedInOrChanged) {
|
||||
isNewMovedInOrChanged = newMovedInOrChanged;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNotExist() {
|
||||
return isNotExist;
|
||||
}
|
||||
|
||||
public void setNotExist(boolean notExist) {
|
||||
isNotExist = notExist;
|
||||
}
|
||||
|
||||
public boolean isPresence() {
|
||||
return isPresence;
|
||||
}
|
||||
|
||||
public void setPresence(boolean presence) {
|
||||
isPresence = presence;
|
||||
}
|
||||
|
||||
public boolean isAbsenceUnexcused() {
|
||||
return isAbsenceUnexcused;
|
||||
}
|
||||
|
||||
public void setAbsenceUnexcused(boolean absenceUnexcused) {
|
||||
isAbsenceUnexcused = absenceUnexcused;
|
||||
}
|
||||
|
||||
public boolean isAbsenceExcused() {
|
||||
return isAbsenceExcused;
|
||||
}
|
||||
|
||||
public void setAbsenceExcused(boolean absenceExcused) {
|
||||
isAbsenceExcused = absenceExcused;
|
||||
}
|
||||
|
||||
public boolean isUnexcusedLateness() {
|
||||
return isUnexcusedLateness;
|
||||
}
|
||||
|
||||
public void setUnexcusedLateness(boolean unexcusedLateness) {
|
||||
isUnexcusedLateness = unexcusedLateness;
|
||||
}
|
||||
|
||||
public boolean isAbsenceForSchoolReasons() {
|
||||
return isAbsenceForSchoolReasons;
|
||||
}
|
||||
|
||||
public void setAbsenceForSchoolReasons(boolean absenceForSchoolReasons) {
|
||||
isAbsenceForSchoolReasons = absenceForSchoolReasons;
|
||||
}
|
||||
|
||||
public boolean isExcusedLateness() {
|
||||
return isExcusedLateness;
|
||||
}
|
||||
|
||||
public void setExcusedLateness(boolean excusedLateness) {
|
||||
isExcusedLateness = excusedLateness;
|
||||
}
|
||||
|
||||
public boolean isExemption() {
|
||||
return isExemption;
|
||||
}
|
||||
|
||||
public void setExemption(boolean exemption) {
|
||||
isExemption = exemption;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
package io.github.wulkanowy.api.generic;
|
||||
|
||||
public class Month {
|
||||
|
@ -1,4 +1,4 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
package io.github.wulkanowy.api.generic;
|
||||
|
||||
public class Subject {
|
||||
|
@ -1,23 +1,23 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
package io.github.wulkanowy.api.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Week {
|
||||
public class Week<T> {
|
||||
|
||||
private List<Day> days = new ArrayList<>();
|
||||
private List<T> days = new ArrayList<>();
|
||||
|
||||
private String startDayDate = "";
|
||||
|
||||
public Day getDay(int index) {
|
||||
public T getDay(int index) {
|
||||
return days.get(index);
|
||||
}
|
||||
|
||||
public List<Day> getDays() {
|
||||
public List<T> getDays() {
|
||||
return days;
|
||||
}
|
||||
|
||||
public Week setDays(List<Day> days) {
|
||||
public Week<T> setDays(List<T> days) {
|
||||
this.days = days;
|
||||
return this;
|
||||
}
|
||||
@ -26,7 +26,7 @@ public class Week {
|
||||
return startDayDate;
|
||||
}
|
||||
|
||||
public Week setStartDayDate(String startDayDate) {
|
||||
public Week<T> setStartDayDate(String startDayDate) {
|
||||
this.startDayDate = startDayDate;
|
||||
return this;
|
||||
}
|
@ -29,7 +29,7 @@ public class GradesList {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public String getGradesPageUrl() {
|
||||
private String getGradesPageUrl() {
|
||||
return GRADES_PAGE_URL;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
class LessonTypes {
|
||||
|
||||
static final String CLASS_PLANNING = "x-treelabel-ppl";
|
||||
|
||||
static final String CLASS_REALIZED = "x-treelabel-rlz";
|
||||
|
||||
static final String CLASS_MOVED_OR_CANCELED = "x-treelabel-inv";
|
||||
|
||||
static final String CLASS_NEW_MOVED_IN_OR_CHANGED = "x-treelabel-zas";
|
||||
|
||||
private LessonTypes() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
}
|
@ -13,6 +13,9 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import io.github.wulkanowy.api.SnP;
|
||||
import io.github.wulkanowy.api.generic.Day;
|
||||
import io.github.wulkanowy.api.generic.Lesson;
|
||||
import io.github.wulkanowy.api.generic.Week;
|
||||
|
||||
public class Timetable {
|
||||
|
||||
@ -24,11 +27,11 @@ public class Timetable {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getWeekTable() throws IOException, ParseException {
|
||||
public Week<Day> getWeekTable() throws IOException, ParseException {
|
||||
return getWeekTable("");
|
||||
}
|
||||
|
||||
public Week getWeekTable(final String tick) throws IOException, ParseException {
|
||||
public Week<Day> getWeekTable(final String tick) throws IOException, ParseException {
|
||||
Element table = snp.getSnPPageDocument(TIMETABLE_PAGE_URL + tick)
|
||||
.select(".mainContainer .presentData").first();
|
||||
|
||||
@ -36,7 +39,7 @@ public class Timetable {
|
||||
|
||||
setLessonToDays(table, days);
|
||||
|
||||
return new Week()
|
||||
return new Week<Day>()
|
||||
.setStartDayDate(days.get(0).getDate())
|
||||
.setDays(days);
|
||||
}
|
||||
@ -125,19 +128,19 @@ public class Timetable {
|
||||
}
|
||||
|
||||
private void addTypeInfo(Lesson lesson, Elements spans) {
|
||||
if (spans.first().hasClass(Lesson.CLASS_PLANNING)) {
|
||||
if (spans.first().hasClass(LessonTypes.CLASS_PLANNING)) {
|
||||
lesson.setPlanning(true);
|
||||
}
|
||||
|
||||
if (spans.first().hasClass(Lesson.CLASS_MOVED_OR_CANCELED)) {
|
||||
if (spans.first().hasClass(LessonTypes.CLASS_MOVED_OR_CANCELED)) {
|
||||
lesson.setMovedOrCanceled(true);
|
||||
}
|
||||
|
||||
if (spans.first().hasClass(Lesson.CLASS_NEW_MOVED_IN_OR_CHANGED)) {
|
||||
if (spans.first().hasClass(LessonTypes.CLASS_NEW_MOVED_IN_OR_CHANGED)) {
|
||||
lesson.setNewMovedInOrChanged(true);
|
||||
}
|
||||
|
||||
if (spans.last().hasClass(Lesson.CLASS_REALIZED) || "".equals(spans.first().attr("class"))) {
|
||||
if (spans.last().hasClass(LessonTypes.CLASS_REALIZED) || "".equals(spans.first().attr("class"))) {
|
||||
lesson.setRealized(true);
|
||||
}
|
||||
}
|
||||
@ -151,7 +154,7 @@ public class Timetable {
|
||||
}
|
||||
|
||||
private void addChangesInfo(Lesson lesson, Elements spans) {
|
||||
if (!spans.last().hasClass(Lesson.CLASS_REALIZED)) {
|
||||
if (!spans.last().hasClass(LessonTypes.CLASS_REALIZED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,11 +186,11 @@ public class Timetable {
|
||||
}
|
||||
|
||||
private void addGroupLessonInfo(Lesson lesson, Elements spans) {
|
||||
if (4 == spans.size() && !spans.last().hasClass(Lesson.CLASS_REALIZED)) {
|
||||
if (4 == spans.size() && !spans.last().hasClass(LessonTypes.CLASS_REALIZED)) {
|
||||
lesson.setRoom(spans.last().text());
|
||||
}
|
||||
|
||||
if ((4 == spans.size() && !spans.last().hasClass(Lesson.CLASS_REALIZED) || 5 == spans.size())) {
|
||||
if ((4 == spans.size() && !spans.last().hasClass(LessonTypes.CLASS_REALIZED) || 5 == spans.size())) {
|
||||
String[] subjectAndGroupInfo = getLessonAndGroupInfoFromSpan(spans.get(0));
|
||||
lesson.setSubject(subjectAndGroupInfo[0]);
|
||||
lesson.setGroupName(subjectAndGroupInfo[1]);
|
||||
|
@ -7,6 +7,7 @@ import org.junit.Test;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParentTestCase;
|
||||
import io.github.wulkanowy.api.generic.Month;
|
||||
|
||||
public class AttendanceStatisticsTest extends StudentAndParentTestCase {
|
||||
|
||||
|
@ -19,23 +19,23 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getWeekTest() throws Exception {
|
||||
Assert.assertEquals("23.10.2017", onePerDay.getCurrent().getStartDate());
|
||||
Assert.assertEquals("23.10.2017", onePerDay.getCurrent().getStartDayDate());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDaysListTest() throws Exception {
|
||||
Assert.assertEquals(3, onePerDay.getCurrent().getDayList().size());
|
||||
Assert.assertEquals(7, onePerDay.getWeek("", false).getDayList().size());
|
||||
Assert.assertEquals(3, onePerDay.getCurrent().getDays().size());
|
||||
Assert.assertEquals(7, onePerDay.getWeek("", false).getDays().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getExamsListTest() throws Exception {
|
||||
List<Day> notEmpty = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> notEmpty = onePerDay.getCurrent().getDays();
|
||||
Assert.assertEquals(1, notEmpty.get(0).getExamList().size());
|
||||
Assert.assertEquals(1, notEmpty.get(1).getExamList().size());
|
||||
Assert.assertEquals(1, notEmpty.get(2).getExamList().size());
|
||||
|
||||
List<Day> emptyToo = onePerDay.getWeek("", false).getDayList();
|
||||
List<ExamDay> emptyToo = onePerDay.getWeek("", false).getDays();
|
||||
Assert.assertEquals(1, emptyToo.get(0).getExamList().size());
|
||||
Assert.assertEquals(1, emptyToo.get(1).getExamList().size());
|
||||
Assert.assertEquals(1, emptyToo.get(4).getExamList().size());
|
||||
@ -43,7 +43,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getDayDateTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("23.10.2017", dayList.get(0).getDate());
|
||||
Assert.assertEquals("24.10.2017", dayList.get(1).getDate());
|
||||
@ -52,7 +52,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getExamSubjectAndGroupTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("Sieci komputerowe 3Ti|zaw2", dayList.get(0).getExamList().get(0).getSubjectAndGroup());
|
||||
Assert.assertEquals("Język angielski 3Ti|J1", dayList.get(1).getExamList().get(0).getSubjectAndGroup());
|
||||
@ -61,7 +61,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getExamTypeTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("Sprawdzian", dayList.get(0).getExamList().get(0).getType());
|
||||
Assert.assertEquals("Sprawdzian", dayList.get(1).getExamList().get(0).getType());
|
||||
@ -70,7 +70,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getExamDescriptionTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("Łącza danych", dayList.get(0).getExamList().get(0).getDescription());
|
||||
Assert.assertEquals("Czasy teraźniejsze", dayList.get(1).getExamList().get(0).getDescription());
|
||||
@ -79,7 +79,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getExamTeacherTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("Adam Wiśniewski [AW]", dayList.get(0).getExamList().get(0).getTeacher());
|
||||
Assert.assertEquals("Natalia Nowak [NN]", dayList.get(1).getExamList().get(0).getTeacher());
|
||||
@ -88,7 +88,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
|
||||
|
||||
@Test
|
||||
public void getExamEntryDateTest() throws Exception {
|
||||
List<Day> dayList = onePerDay.getCurrent().getDayList();
|
||||
List<ExamDay> dayList = onePerDay.getCurrent().getDays();
|
||||
|
||||
Assert.assertEquals("16.10.2017", dayList.get(0).getExamList().get(0).getEntryDate());
|
||||
Assert.assertEquals("17.10.2017", dayList.get(1).getExamList().get(0).getEntryDate());
|
||||
|
@ -37,7 +37,7 @@ public class TimetableTest extends StudentAndParentTestCase {
|
||||
Assert.assertEquals("2017-07-31", holidays.getWeekTable().getStartDayDate());
|
||||
}
|
||||
|
||||
// Day
|
||||
// ExamDay
|
||||
|
||||
@Test
|
||||
public void getDayNameTest() throws Exception {
|
||||
|
@ -42,7 +42,8 @@ public class TimetableSync implements TimetableSyncContract {
|
||||
public void syncTimetable(String date) throws NotLoggedInErrorException, IOException, ParseException {
|
||||
long userId = sharedPref.getCurrentUserId();
|
||||
|
||||
io.github.wulkanowy.api.timetable.Week weekFromNet = date == null ? vulcan.getTimetable().getWeekTable()
|
||||
io.github.wulkanowy.api.generic.Week<io.github.wulkanowy.api.generic.Day> weekFromNet =
|
||||
date == null ? vulcan.getTimetable().getWeekTable()
|
||||
: vulcan.getTimetable().getWeekTable(String.valueOf(TimeUtils.getNetTicks(date)));
|
||||
|
||||
Week weekFromDb = daoSession.getWeekDao().queryBuilder()
|
||||
@ -59,11 +60,11 @@ public class TimetableSync implements TimetableSyncContract {
|
||||
weekId = weekFromDb.getId();
|
||||
}
|
||||
|
||||
List<io.github.wulkanowy.api.timetable.Day> dayListFromNet = weekFromNet.getDays();
|
||||
List<io.github.wulkanowy.api.generic.Day> dayListFromNet = weekFromNet.getDays();
|
||||
|
||||
List<Lesson> updatedLessonList = new ArrayList<>();
|
||||
|
||||
for (io.github.wulkanowy.api.timetable.Day dayFromNet : dayListFromNet) {
|
||||
for (io.github.wulkanowy.api.generic.Day dayFromNet : dayListFromNet) {
|
||||
Day dayFromNetEntity = DataObjectConverter.dayToDayEntity(dayFromNet);
|
||||
|
||||
Day dayFromDb = daoSession.getDayDao().queryBuilder()
|
||||
|
@ -52,11 +52,11 @@ public final class DataObjectConverter {
|
||||
return gradeEntityList;
|
||||
}
|
||||
|
||||
public static Week weekToWeekEntity(io.github.wulkanowy.api.timetable.Week week) {
|
||||
public static Week weekToWeekEntity(io.github.wulkanowy.api.generic.Week week) {
|
||||
return new Week().setStartDayDate(week.getStartDayDate());
|
||||
}
|
||||
|
||||
public static Day dayToDayEntity(io.github.wulkanowy.api.timetable.Day day) {
|
||||
public static Day dayToDayEntity(io.github.wulkanowy.api.generic.Day day) {
|
||||
return new Day()
|
||||
.setDate(day.getDate())
|
||||
.setDayName(day.getDayName())
|
||||
@ -65,17 +65,17 @@ public final class DataObjectConverter {
|
||||
}
|
||||
|
||||
|
||||
public static List<Day> daysToDaysEntities(List<io.github.wulkanowy.api.timetable.Day> dayList) {
|
||||
public static List<Day> daysToDaysEntities(List<io.github.wulkanowy.api.generic.Day> dayList) {
|
||||
|
||||
List<Day> dayEntityList = new ArrayList<>();
|
||||
|
||||
for (io.github.wulkanowy.api.timetable.Day day : dayList) {
|
||||
for (io.github.wulkanowy.api.generic.Day day : dayList) {
|
||||
dayEntityList.add(dayToDayEntity(day));
|
||||
}
|
||||
return dayEntityList;
|
||||
}
|
||||
|
||||
public static Lesson lessonToLessonEntity(io.github.wulkanowy.api.timetable.Lesson lesson) {
|
||||
public static Lesson lessonToLessonEntity(io.github.wulkanowy.api.generic.Lesson lesson) {
|
||||
return new Lesson()
|
||||
.setNumber(lesson.getNumber())
|
||||
.setSubject(lesson.getSubject())
|
||||
@ -94,11 +94,11 @@ public final class DataObjectConverter {
|
||||
.setNewMovedInOrChanged(lesson.isNewMovedInOrChanged());
|
||||
}
|
||||
|
||||
public static List<Lesson> lessonsToLessonsEntities(List<io.github.wulkanowy.api.timetable.Lesson> lessonList) {
|
||||
public static List<Lesson> lessonsToLessonsEntities(List<io.github.wulkanowy.api.generic.Lesson> lessonList) {
|
||||
|
||||
List<Lesson> lessonEntityList = new ArrayList<>();
|
||||
|
||||
for (io.github.wulkanowy.api.timetable.Lesson lesson : lessonList) {
|
||||
for (io.github.wulkanowy.api.generic.Lesson lesson : lessonList) {
|
||||
lessonEntityList.add(lessonToLessonEntity(lesson));
|
||||
}
|
||||
return lessonEntityList;
|
||||
|
@ -8,8 +8,8 @@ import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.grades.Grade;
|
||||
import io.github.wulkanowy.api.grades.Subject;
|
||||
import io.github.wulkanowy.api.timetable.Day;
|
||||
import io.github.wulkanowy.api.timetable.Lesson;
|
||||
import io.github.wulkanowy.api.generic.Day;
|
||||
import io.github.wulkanowy.api.generic.Lesson;
|
||||
|
||||
public class DataObjectConverterTest {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user