1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 03:19:09 -05:00

[API] Remove duplicated POJOs (#53)

This commit is contained in:
Mikołaj Pich 2018-03-04 13:24:37 +01:00 committed by Rafał Borcz
parent 79bdbbbb16
commit 4c7c2a1101
24 changed files with 215 additions and 329 deletions

View File

@ -9,6 +9,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.github.wulkanowy.api.SnP; import io.github.wulkanowy.api.SnP;
import io.github.wulkanowy.api.generic.Month;
import io.github.wulkanowy.api.generic.Subject;
public class AttendanceStatistics { public class AttendanceStatistics {

View File

@ -8,6 +8,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.github.wulkanowy.api.SnP; 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 { public class AttendanceTable {
@ -19,11 +22,11 @@ public class AttendanceTable {
this.snp = snp; this.snp = snp;
} }
public Week getWeekTable() throws IOException { public Week<Day> getWeekTable() throws IOException {
return getWeekTable(""); return getWeekTable("");
} }
public Week getWeekTable(String tick) throws IOException { public Week<Day> getWeekTable(String tick) throws IOException {
Element table = snp.getSnPPageDocument(attendancePageUrl + tick) Element table = snp.getSnPPageDocument(attendancePageUrl + tick)
.select(".mainContainer .presentData").first(); .select(".mainContainer .presentData").first();
@ -49,7 +52,7 @@ public class AttendanceTable {
String[] dayDescription = headerCells.get(1).html().split("<br>"); String[] dayDescription = headerCells.get(1).html().split("<br>");
return new Week() return new Week<Day>()
.setStartDayDate(dayDescription[1]) .setStartDayDate(dayDescription[1])
.setDays(days); .setDays(days);
} }
@ -58,7 +61,7 @@ public class AttendanceTable {
Lesson lesson = new Lesson(); Lesson lesson = new Lesson();
lesson.setSubject(cell.select("span").text()); 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.setNotExist(true);
lesson.setEmpty(true); lesson.setEmpty(true);
@ -66,25 +69,25 @@ public class AttendanceTable {
} }
switch (cell.select("div").attr("class")) { switch (cell.select("div").attr("class")) {
case Lesson.CLASS_PRESENCE: case LessonTypes.CLASS_PRESENCE:
lesson.setPresence(true); lesson.setPresence(true);
break; break;
case Lesson.CLASS_ABSENCE_UNEXCUSED: case LessonTypes.CLASS_ABSENCE_UNEXCUSED:
lesson.setAbsenceUnexcused(true); lesson.setAbsenceUnexcused(true);
break; break;
case Lesson.CLASS_ABSENCE_EXCUSED: case LessonTypes.CLASS_ABSENCE_EXCUSED:
lesson.setAbsenceExcused(true); lesson.setAbsenceExcused(true);
break; break;
case Lesson.CLASS_ABSENCE_FOR_SCHOOL_REASONS: case LessonTypes.CLASS_ABSENCE_FOR_SCHOOL_REASONS:
lesson.setAbsenceForSchoolReasons(true); lesson.setAbsenceForSchoolReasons(true);
break; break;
case Lesson.CLASS_UNEXCUSED_LATENESS: case LessonTypes.CLASS_UNEXCUSED_LATENESS:
lesson.setUnexcusedLateness(true); lesson.setUnexcusedLateness(true);
break; break;
case Lesson.CLASS_EXCUSED_LATENESS: case LessonTypes.CLASS_EXCUSED_LATENESS:
lesson.setExcusedLateness(true); lesson.setExcusedLateness(true);
break; break;
case Lesson.CLASS_EXEMPTION: case LessonTypes.CLASS_EXEMPTION:
lesson.setExemption(true); lesson.setExemption(true);
break; break;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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");
}
}

View File

@ -3,6 +3,8 @@ package io.github.wulkanowy.api.attendance;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.github.wulkanowy.api.generic.Month;
public class Type { public class Type {
private String name = ""; private String name = "";

View File

@ -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;
}
}

View File

@ -3,27 +3,17 @@ package io.github.wulkanowy.api.exams;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 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() { public List<Exam> getExamList() {
return examList; return examList;
} }
public Day addExam(Exam exam) { public void addExam(Exam exam) {
this.examList.add(exam); this.examList.add(exam);
return this;
} }
} }

View File

@ -9,6 +9,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.github.wulkanowy.api.SnP; import io.github.wulkanowy.api.SnP;
import io.github.wulkanowy.api.generic.Week;
public class ExamsWeek { public class ExamsWeek {
@ -20,18 +21,18 @@ public class ExamsWeek {
this.snp = snp; this.snp = snp;
} }
public Week getCurrent() throws IOException { public Week<ExamDay> getCurrent() throws IOException {
return getWeek("", true); 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); Document examsPage = snp.getSnPPageDocument(EXAMS_PAGE_URL + tick);
Elements examsDays = examsPage.select(".mainContainer > div:not(.navigation)"); Elements examsDays = examsPage.select(".mainContainer > div:not(.navigation)");
List<Day> days = new ArrayList<>(); List<ExamDay> days = new ArrayList<>();
for (Element item : examsDays) { for (Element item : examsDays) {
Day day = new Day(); ExamDay day = new ExamDay();
Element dayHeading = item.select("h2").first(); Element dayHeading = item.select("h2").first();
if (null == dayHeading && onlyNotEmpty) { if (null == dayHeading && onlyNotEmpty) {
@ -39,7 +40,7 @@ public class ExamsWeek {
} }
if (null != dayHeading) { if (null != dayHeading) {
day = new Day().setDate(dayHeading.text().split(", ")[1]); day.setDate(dayHeading.text().split(", ")[1]);
} }
Elements exams = item.select("article"); Elements exams = item.select("article");
@ -56,10 +57,8 @@ public class ExamsWeek {
days.add(day); days.add(day);
} }
Week week = new Week(); return new Week<ExamDay>()
week.setStartDate(examsDays.select("h2").first().text().split(" ")[1]); .setStartDayDate(examsDays.select("h2").first().text().split(" ")[1])
week.setDayList(days); .setDays(days);
return week;
} }
} }

View File

@ -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;
}
}

View File

@ -1,4 +1,4 @@
package io.github.wulkanowy.api.timetable; package io.github.wulkanowy.api.generic;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -7,7 +7,7 @@ public class Day {
private List<Lesson> lessons = new ArrayList<>(); private List<Lesson> lessons = new ArrayList<>();
private String date = ""; protected String date = "";
private String dayName = ""; private String dayName = "";
@ -41,26 +41,23 @@ public class Day {
return dayName; return dayName;
} }
public Day setDayName(String dayName) { public void setDayName(String dayName) {
this.dayName = dayName; this.dayName = dayName;
return this;
} }
public boolean isFreeDay() { public boolean isFreeDay() {
return isFreeDay; return isFreeDay;
} }
public Day setFreeDay(boolean freeDay) { public void setFreeDay(boolean freeDay) {
isFreeDay = freeDay; isFreeDay = freeDay;
return this;
} }
public String getFreeDayName() { public String getFreeDayName() {
return freeDayName; return freeDayName;
} }
public Day setFreeDayName(String freeDayName) { public void setFreeDayName(String freeDayName) {
this.freeDayName = freeDayName; this.freeDayName = freeDayName;
return this;
} }
} }

View File

@ -1,15 +1,7 @@
package io.github.wulkanowy.api.timetable; package io.github.wulkanowy.api.generic;
public class Lesson { 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 number = "";
private String subject = ""; private String subject = "";
@ -40,13 +32,28 @@ public class Lesson {
private boolean isNewMovedInOrChanged = false; 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() { public String getNumber() {
return number; return number;
} }
public Lesson setNumber(String number) { public void setNumber(String number) {
this.number = number; this.number = number;
return this;
} }
public String getSubject() { public String getSubject() {
@ -89,27 +96,24 @@ public class Lesson {
return groupName; return groupName;
} }
public Lesson setGroupName(String groupName) { public void setGroupName(String groupName) {
this.groupName = groupName; this.groupName = groupName;
return this;
} }
public String getStartTime() { public String getStartTime() {
return startTime; return startTime;
} }
public Lesson setStartTime(String startTime) { public void setStartTime(String startTime) {
this.startTime = startTime; this.startTime = startTime;
return this;
} }
public String getEndTime() { public String getEndTime() {
return endTime; return endTime;
} }
public Lesson setEndTime(String endTime) { public void setEndTime(String endTime) {
this.endTime = endTime; this.endTime = endTime;
return this;
} }
public String getDate() { public String getDate() {
@ -134,44 +138,103 @@ public class Lesson {
return isDivisionIntoGroups; return isDivisionIntoGroups;
} }
public Lesson setDivisionIntoGroups(boolean divisionIntoGroups) { public void setDivisionIntoGroups(boolean divisionIntoGroups) {
isDivisionIntoGroups = divisionIntoGroups; isDivisionIntoGroups = divisionIntoGroups;
return this;
} }
public boolean isPlanning() { public boolean isPlanning() {
return isPlanning; return isPlanning;
} }
public Lesson setPlanning(boolean planning) { public void setPlanning(boolean planning) {
isPlanning = planning; isPlanning = planning;
return this;
} }
public boolean isRealized() { public boolean isRealized() {
return isRealized; return isRealized;
} }
public Lesson setRealized(boolean realized) { public void setRealized(boolean realized) {
isRealized = realized; isRealized = realized;
return this;
} }
public boolean isMovedOrCanceled() { public boolean isMovedOrCanceled() {
return isMovedOrCanceled; return isMovedOrCanceled;
} }
public Lesson setMovedOrCanceled(boolean movedOrCanceled) { public void setMovedOrCanceled(boolean movedOrCanceled) {
isMovedOrCanceled = movedOrCanceled; isMovedOrCanceled = movedOrCanceled;
return this;
} }
public boolean isNewMovedInOrChanged() { public boolean isNewMovedInOrChanged() {
return isNewMovedInOrChanged; return isNewMovedInOrChanged;
} }
public Lesson setNewMovedInOrChanged(boolean newMovedInOrChanged) { public void setNewMovedInOrChanged(boolean newMovedInOrChanged) {
isNewMovedInOrChanged = 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;
} }
} }

View File

@ -1,4 +1,4 @@
package io.github.wulkanowy.api.attendance; package io.github.wulkanowy.api.generic;
public class Month { public class Month {

View File

@ -1,4 +1,4 @@
package io.github.wulkanowy.api.attendance; package io.github.wulkanowy.api.generic;
public class Subject { public class Subject {

View File

@ -1,23 +1,23 @@
package io.github.wulkanowy.api.timetable; package io.github.wulkanowy.api.generic;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 = ""; private String startDayDate = "";
public Day getDay(int index) { public T getDay(int index) {
return days.get(index); return days.get(index);
} }
public List<Day> getDays() { public List<T> getDays() {
return days; return days;
} }
public Week setDays(List<Day> days) { public Week<T> setDays(List<T> days) {
this.days = days; this.days = days;
return this; return this;
} }
@ -26,7 +26,7 @@ public class Week {
return startDayDate; return startDayDate;
} }
public Week setStartDayDate(String startDayDate) { public Week<T> setStartDayDate(String startDayDate) {
this.startDayDate = startDayDate; this.startDayDate = startDayDate;
return this; return this;
} }

View File

@ -29,7 +29,7 @@ public class GradesList {
this.snp = snp; this.snp = snp;
} }
public String getGradesPageUrl() { private String getGradesPageUrl() {
return GRADES_PAGE_URL; return GRADES_PAGE_URL;
} }

View File

@ -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");
}
}

View File

@ -13,6 +13,9 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import io.github.wulkanowy.api.SnP; 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 { public class Timetable {
@ -24,11 +27,11 @@ public class Timetable {
this.snp = snp; this.snp = snp;
} }
public Week getWeekTable() throws IOException, ParseException { public Week<Day> getWeekTable() throws IOException, ParseException {
return getWeekTable(""); 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) Element table = snp.getSnPPageDocument(TIMETABLE_PAGE_URL + tick)
.select(".mainContainer .presentData").first(); .select(".mainContainer .presentData").first();
@ -36,7 +39,7 @@ public class Timetable {
setLessonToDays(table, days); setLessonToDays(table, days);
return new Week() return new Week<Day>()
.setStartDayDate(days.get(0).getDate()) .setStartDayDate(days.get(0).getDate())
.setDays(days); .setDays(days);
} }
@ -125,19 +128,19 @@ public class Timetable {
} }
private void addTypeInfo(Lesson lesson, Elements spans) { private void addTypeInfo(Lesson lesson, Elements spans) {
if (spans.first().hasClass(Lesson.CLASS_PLANNING)) { if (spans.first().hasClass(LessonTypes.CLASS_PLANNING)) {
lesson.setPlanning(true); lesson.setPlanning(true);
} }
if (spans.first().hasClass(Lesson.CLASS_MOVED_OR_CANCELED)) { if (spans.first().hasClass(LessonTypes.CLASS_MOVED_OR_CANCELED)) {
lesson.setMovedOrCanceled(true); 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); 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); lesson.setRealized(true);
} }
} }
@ -151,7 +154,7 @@ public class Timetable {
} }
private void addChangesInfo(Lesson lesson, Elements spans) { private void addChangesInfo(Lesson lesson, Elements spans) {
if (!spans.last().hasClass(Lesson.CLASS_REALIZED)) { if (!spans.last().hasClass(LessonTypes.CLASS_REALIZED)) {
return; return;
} }
@ -183,11 +186,11 @@ public class Timetable {
} }
private void addGroupLessonInfo(Lesson lesson, Elements spans) { 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()); 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)); String[] subjectAndGroupInfo = getLessonAndGroupInfoFromSpan(spans.get(0));
lesson.setSubject(subjectAndGroupInfo[0]); lesson.setSubject(subjectAndGroupInfo[0]);
lesson.setGroupName(subjectAndGroupInfo[1]); lesson.setGroupName(subjectAndGroupInfo[1]);

View File

@ -7,6 +7,7 @@ import org.junit.Test;
import java.util.List; import java.util.List;
import io.github.wulkanowy.api.StudentAndParentTestCase; import io.github.wulkanowy.api.StudentAndParentTestCase;
import io.github.wulkanowy.api.generic.Month;
public class AttendanceStatisticsTest extends StudentAndParentTestCase { public class AttendanceStatisticsTest extends StudentAndParentTestCase {

View File

@ -19,23 +19,23 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
@Test @Test
public void getWeekTest() throws Exception { public void getWeekTest() throws Exception {
Assert.assertEquals("23.10.2017", onePerDay.getCurrent().getStartDate()); Assert.assertEquals("23.10.2017", onePerDay.getCurrent().getStartDayDate());
} }
@Test @Test
public void getDaysListTest() throws Exception { public void getDaysListTest() throws Exception {
Assert.assertEquals(3, onePerDay.getCurrent().getDayList().size()); Assert.assertEquals(3, onePerDay.getCurrent().getDays().size());
Assert.assertEquals(7, onePerDay.getWeek("", false).getDayList().size()); Assert.assertEquals(7, onePerDay.getWeek("", false).getDays().size());
} }
@Test @Test
public void getExamsListTest() throws Exception { 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(0).getExamList().size());
Assert.assertEquals(1, notEmpty.get(1).getExamList().size()); Assert.assertEquals(1, notEmpty.get(1).getExamList().size());
Assert.assertEquals(1, notEmpty.get(2).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(0).getExamList().size());
Assert.assertEquals(1, emptyToo.get(1).getExamList().size()); Assert.assertEquals(1, emptyToo.get(1).getExamList().size());
Assert.assertEquals(1, emptyToo.get(4).getExamList().size()); Assert.assertEquals(1, emptyToo.get(4).getExamList().size());
@ -43,7 +43,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
@Test @Test
public void getDayDateTest() throws Exception { 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("23.10.2017", dayList.get(0).getDate());
Assert.assertEquals("24.10.2017", dayList.get(1).getDate()); Assert.assertEquals("24.10.2017", dayList.get(1).getDate());
@ -52,7 +52,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
@Test @Test
public void getExamSubjectAndGroupTest() throws Exception { 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("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()); Assert.assertEquals("Język angielski 3Ti|J1", dayList.get(1).getExamList().get(0).getSubjectAndGroup());
@ -61,7 +61,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
@Test @Test
public void getExamTypeTest() throws Exception { 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(0).getExamList().get(0).getType());
Assert.assertEquals("Sprawdzian", dayList.get(1).getExamList().get(0).getType()); Assert.assertEquals("Sprawdzian", dayList.get(1).getExamList().get(0).getType());
@ -70,7 +70,7 @@ public class ExamsWeekTest extends StudentAndParentTestCase {
@Test @Test
public void getExamDescriptionTest() throws Exception { 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("Łącza danych", dayList.get(0).getExamList().get(0).getDescription());
Assert.assertEquals("Czasy teraźniejsze", dayList.get(1).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 @Test
public void getExamTeacherTest() throws Exception { 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("Adam Wiśniewski [AW]", dayList.get(0).getExamList().get(0).getTeacher());
Assert.assertEquals("Natalia Nowak [NN]", dayList.get(1).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 @Test
public void getExamEntryDateTest() throws Exception { 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("16.10.2017", dayList.get(0).getExamList().get(0).getEntryDate());
Assert.assertEquals("17.10.2017", dayList.get(1).getExamList().get(0).getEntryDate()); Assert.assertEquals("17.10.2017", dayList.get(1).getExamList().get(0).getEntryDate());

View File

@ -37,7 +37,7 @@ public class TimetableTest extends StudentAndParentTestCase {
Assert.assertEquals("2017-07-31", holidays.getWeekTable().getStartDayDate()); Assert.assertEquals("2017-07-31", holidays.getWeekTable().getStartDayDate());
} }
// Day // ExamDay
@Test @Test
public void getDayNameTest() throws Exception { public void getDayNameTest() throws Exception {

View File

@ -42,7 +42,8 @@ public class TimetableSync implements TimetableSyncContract {
public void syncTimetable(String date) throws NotLoggedInErrorException, IOException, ParseException { public void syncTimetable(String date) throws NotLoggedInErrorException, IOException, ParseException {
long userId = sharedPref.getCurrentUserId(); 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))); : vulcan.getTimetable().getWeekTable(String.valueOf(TimeUtils.getNetTicks(date)));
Week weekFromDb = daoSession.getWeekDao().queryBuilder() Week weekFromDb = daoSession.getWeekDao().queryBuilder()
@ -59,11 +60,11 @@ public class TimetableSync implements TimetableSyncContract {
weekId = weekFromDb.getId(); 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<>(); 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 dayFromNetEntity = DataObjectConverter.dayToDayEntity(dayFromNet);
Day dayFromDb = daoSession.getDayDao().queryBuilder() Day dayFromDb = daoSession.getDayDao().queryBuilder()

View File

@ -52,11 +52,11 @@ public final class DataObjectConverter {
return gradeEntityList; 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()); 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() return new Day()
.setDate(day.getDate()) .setDate(day.getDate())
.setDayName(day.getDayName()) .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<>(); 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)); dayEntityList.add(dayToDayEntity(day));
} }
return dayEntityList; 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() return new Lesson()
.setNumber(lesson.getNumber()) .setNumber(lesson.getNumber())
.setSubject(lesson.getSubject()) .setSubject(lesson.getSubject())
@ -94,11 +94,11 @@ public final class DataObjectConverter {
.setNewMovedInOrChanged(lesson.isNewMovedInOrChanged()); .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<>(); 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)); lessonEntityList.add(lessonToLessonEntity(lesson));
} }
return lessonEntityList; return lessonEntityList;

View File

@ -8,8 +8,8 @@ import java.util.List;
import io.github.wulkanowy.api.grades.Grade; import io.github.wulkanowy.api.grades.Grade;
import io.github.wulkanowy.api.grades.Subject; import io.github.wulkanowy.api.grades.Subject;
import io.github.wulkanowy.api.timetable.Day; import io.github.wulkanowy.api.generic.Day;
import io.github.wulkanowy.api.timetable.Lesson; import io.github.wulkanowy.api.generic.Lesson;
public class DataObjectConverterTest { public class DataObjectConverterTest {