API as java module (#34)
This commit is contained in:

committed by
Rafał Borcz

parent
428b372827
commit
29d12b79ca
@ -1,49 +0,0 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class Api {
|
||||
|
||||
protected Cookies cookies = new Cookies();
|
||||
|
||||
public Cookies getCookiesObject() {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
public Map<String, String> getCookies() {
|
||||
return cookies.getItems();
|
||||
}
|
||||
|
||||
public Document getPageByUrl(String url) throws IOException {
|
||||
Connection.Response response = Jsoup.connect(url)
|
||||
.followRedirects(true)
|
||||
.cookies(getCookies())
|
||||
.execute();
|
||||
|
||||
this.cookies.addItems(response.cookies());
|
||||
|
||||
return response.parse();
|
||||
}
|
||||
|
||||
public Document postPageByUrl(String url, String[][] params) throws IOException {
|
||||
Connection connection = Jsoup.connect(url);
|
||||
|
||||
for (String[] data : params) {
|
||||
connection.data(data[0], data[1]);
|
||||
}
|
||||
|
||||
Connection.Response response = connection.cookies(getCookies())
|
||||
.followRedirects(true)
|
||||
.method(Connection.Method.POST)
|
||||
.execute();
|
||||
|
||||
this.cookies.addItems(response.cookies());
|
||||
|
||||
return response.parse();
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Cookies {
|
||||
|
||||
private Map<String, String> cookies = new HashMap<>();
|
||||
|
||||
public Map<String, String> getItems() {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
public Cookies setItems(Map<String, String> items) {
|
||||
this.cookies = items;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Cookies addItems(Map<String, String> items) {
|
||||
this.cookies.putAll(items);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
public class Semester {
|
||||
|
||||
private String number = "";
|
||||
|
||||
private String id = "";
|
||||
|
||||
private boolean isCurrent = false;
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public Semester setNumber(String number) {
|
||||
this.number = number;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Semester setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isCurrent() {
|
||||
return isCurrent;
|
||||
}
|
||||
|
||||
public Semester setCurrent(boolean current) {
|
||||
isCurrent = current;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.login.NotLoggedInErrorException;
|
||||
|
||||
public class StudentAndParent extends Api {
|
||||
|
||||
private String startPageUrl = "https://uonetplus.vulcan.net.pl/{symbol}/Start.mvc/Index";
|
||||
|
||||
private String baseUrl = "https://uonetplus-opiekun.vulcan.net.pl/{symbol}/{ID}/";
|
||||
|
||||
private String gradesPageUrl = baseUrl + "Oceny/Wszystkie";
|
||||
|
||||
private String symbol;
|
||||
|
||||
private String id;
|
||||
|
||||
public StudentAndParent(Cookies cookies, String symbol) {
|
||||
this.cookies = cookies;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public StudentAndParent(Cookies cookies, String symbol, String id) {
|
||||
this(cookies, symbol);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getGradesPageUrl() {
|
||||
return gradesPageUrl;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public String getStartPageUrl() {
|
||||
return startPageUrl;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void storeContextCookies() throws IOException, NotLoggedInErrorException {
|
||||
getPageByUrl(getSnpPageUrl());
|
||||
}
|
||||
|
||||
public String getSnpPageUrl() throws IOException, NotLoggedInErrorException {
|
||||
if (null != getId()) {
|
||||
return getBaseUrl().replace("{symbol}", getSymbol()).replace("{ID}", getId());
|
||||
}
|
||||
|
||||
// get url to uonetplus-opiekun.vulcan.net.pl
|
||||
Document startPage = getPageByUrl(getStartPageUrl().replace("{symbol}", getSymbol()));
|
||||
Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first();
|
||||
|
||||
if (null == studentTileLink) {
|
||||
throw new NotLoggedInErrorException();
|
||||
}
|
||||
|
||||
String snpPageUrl = studentTileLink.attr("href");
|
||||
|
||||
this.id = getExtractedIdFromUrl(snpPageUrl);
|
||||
|
||||
return snpPageUrl;
|
||||
}
|
||||
|
||||
public String getExtractedIdFromUrl(String snpPageUrl) throws NotLoggedInErrorException {
|
||||
String[] path = snpPageUrl.split("vulcan.net.pl/")[1].split("/");
|
||||
|
||||
if (4 != path.length) {
|
||||
throw new NotLoggedInErrorException();
|
||||
}
|
||||
|
||||
return path[1];
|
||||
}
|
||||
|
||||
public String getRowDataChildValue(Element e, int index) {
|
||||
return e.select(".daneWiersz .wartosc").get(index - 1).text();
|
||||
}
|
||||
|
||||
public Document getSnPPageDocument(String url) throws IOException {
|
||||
return getPageByUrl(getBaseUrl()
|
||||
.replace("{symbol}", getSymbol())
|
||||
.replace("{ID}", getId()) + url);
|
||||
}
|
||||
|
||||
public List<Semester> getSemesters() throws IOException {
|
||||
return getSemesters(getSnPPageDocument(getGradesPageUrl()));
|
||||
}
|
||||
|
||||
public List<Semester> getSemesters(Document gradesPage) {
|
||||
Elements semesterOptions = gradesPage.select("#okresyKlasyfikacyjneDropDownList option");
|
||||
|
||||
List<Semester> semesters = new ArrayList<>();
|
||||
|
||||
for (Element e : semesterOptions) {
|
||||
Semester semester = new Semester()
|
||||
.setId(e.text())
|
||||
.setNumber(e.attr("value"));
|
||||
|
||||
if ("selected".equals(e.attr("selected"))) {
|
||||
semester.setCurrent(true);
|
||||
}
|
||||
|
||||
semesters.add(semester);
|
||||
}
|
||||
|
||||
return semesters;
|
||||
}
|
||||
|
||||
public Semester getCurrentSemester(List<Semester> semesterList) {
|
||||
Semester current = null;
|
||||
for (Semester s : semesterList) {
|
||||
if (s.isCurrent()) {
|
||||
current = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
}
|
@ -1,124 +0,0 @@
|
||||
package io.github.wulkanowy.api;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.github.wulkanowy.api.attendance.AttendanceStatistics;
|
||||
import io.github.wulkanowy.api.attendance.AttendanceTable;
|
||||
import io.github.wulkanowy.api.exams.ExamsWeek;
|
||||
import io.github.wulkanowy.api.grades.GradesList;
|
||||
import io.github.wulkanowy.api.grades.SubjectsList;
|
||||
import io.github.wulkanowy.api.login.AccountPermissionException;
|
||||
import io.github.wulkanowy.api.login.BadCredentialsException;
|
||||
import io.github.wulkanowy.api.login.Login;
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
import io.github.wulkanowy.api.login.NotLoggedInErrorException;
|
||||
import io.github.wulkanowy.api.notes.AchievementsList;
|
||||
import io.github.wulkanowy.api.notes.NotesList;
|
||||
import io.github.wulkanowy.api.school.SchoolInfo;
|
||||
import io.github.wulkanowy.api.school.TeachersInfo;
|
||||
import io.github.wulkanowy.api.timetable.Timetable;
|
||||
import io.github.wulkanowy.api.user.BasicInformation;
|
||||
import io.github.wulkanowy.api.user.FamilyInformation;
|
||||
|
||||
public class Vulcan extends Api {
|
||||
|
||||
private String id;
|
||||
|
||||
private String symbol;
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
public void login(Cookies cookies, String symbol) {
|
||||
this.cookies = cookies;
|
||||
this.symbol = symbol;
|
||||
}
|
||||
|
||||
public void login(String email, String password, String symbol)
|
||||
throws BadCredentialsException, AccountPermissionException, LoginErrorException, IOException {
|
||||
Login login = new Login(new Cookies());
|
||||
String realSymbol = login.login(email, password, symbol);
|
||||
|
||||
login(login.getCookiesObject(), realSymbol);
|
||||
}
|
||||
|
||||
public void login(String email, String password, String symbol, String id)
|
||||
throws BadCredentialsException, AccountPermissionException, LoginErrorException, IOException {
|
||||
login(email, password, symbol);
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public StudentAndParent getStudentAndParent() throws IOException, NotLoggedInErrorException {
|
||||
if (null == getCookiesObject()) {
|
||||
throw new NotLoggedInErrorException();
|
||||
}
|
||||
|
||||
if (null != snp) {
|
||||
return snp;
|
||||
}
|
||||
|
||||
snp = createSnp(cookies, symbol, id);
|
||||
|
||||
snp.storeContextCookies();
|
||||
|
||||
this.cookies = snp.getCookiesObject();
|
||||
|
||||
return snp;
|
||||
}
|
||||
|
||||
public StudentAndParent createSnp(Cookies cookies, String symbol, String id) {
|
||||
if (null == id) {
|
||||
return new StudentAndParent(cookies, symbol);
|
||||
}
|
||||
|
||||
return new StudentAndParent(cookies, symbol, id);
|
||||
}
|
||||
|
||||
public AttendanceStatistics getAttendanceStatistics() throws IOException, NotLoggedInErrorException {
|
||||
return new AttendanceStatistics(getStudentAndParent());
|
||||
}
|
||||
|
||||
public AttendanceTable getAttendanceTable() throws IOException, NotLoggedInErrorException {
|
||||
return new AttendanceTable(getStudentAndParent());
|
||||
}
|
||||
|
||||
public ExamsWeek getExamsList() throws IOException, NotLoggedInErrorException {
|
||||
return new ExamsWeek(getStudentAndParent());
|
||||
}
|
||||
|
||||
public GradesList getGradesList() throws IOException, NotLoggedInErrorException {
|
||||
return new GradesList(getStudentAndParent());
|
||||
}
|
||||
|
||||
public SubjectsList getSubjectsList() throws IOException, NotLoggedInErrorException {
|
||||
return new SubjectsList(getStudentAndParent());
|
||||
}
|
||||
|
||||
public AchievementsList getAchievementsList() throws IOException, NotLoggedInErrorException {
|
||||
return new AchievementsList(getStudentAndParent());
|
||||
}
|
||||
|
||||
public NotesList getNotesList() throws IOException, NotLoggedInErrorException {
|
||||
return new NotesList(getStudentAndParent());
|
||||
}
|
||||
|
||||
public SchoolInfo getSchoolInfo() throws IOException, NotLoggedInErrorException {
|
||||
return new SchoolInfo(getStudentAndParent());
|
||||
}
|
||||
|
||||
public TeachersInfo getTeachersInfo() throws IOException, NotLoggedInErrorException {
|
||||
return new TeachersInfo(getStudentAndParent());
|
||||
}
|
||||
|
||||
public Timetable getTimetable() throws IOException, NotLoggedInErrorException {
|
||||
return new Timetable(getStudentAndParent());
|
||||
}
|
||||
|
||||
public BasicInformation getBasicInformation() throws IOException, NotLoggedInErrorException {
|
||||
return new BasicInformation(getStudentAndParent());
|
||||
}
|
||||
|
||||
public FamilyInformation getFamilyInformation() throws IOException, NotLoggedInErrorException {
|
||||
return new FamilyInformation(getStudentAndParent());
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class AttendanceStatistics {
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
private String attendancePageUrl = "Frekwencja.mvc";
|
||||
|
||||
public AttendanceStatistics(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Types getTypesTable() throws IOException {
|
||||
return getTypesTable("");
|
||||
}
|
||||
|
||||
public Types getTypesTable(String tick) throws IOException {
|
||||
return getTypesTable(tick, -1);
|
||||
}
|
||||
|
||||
public List<Subject> getSubjectList() throws IOException {
|
||||
Element mainContainer = snp.getSnPPageDocument(attendancePageUrl)
|
||||
.select(".mainContainer #idPrzedmiot").first();
|
||||
|
||||
List<Subject> subjectList = new ArrayList<>();
|
||||
|
||||
for (Element subject : mainContainer.select("option")) {
|
||||
subjectList.add(new Subject()
|
||||
.setId(Integer.parseInt(subject.attr("value")))
|
||||
.setName(subject.text())
|
||||
);
|
||||
}
|
||||
|
||||
return subjectList;
|
||||
}
|
||||
|
||||
public Types getTypesTable(String tick, Integer subjectId) throws IOException {
|
||||
Element mainContainer = snp.getSnPPageDocument((attendancePageUrl
|
||||
+ "?data={tick}&idPrzedmiot={subject}")
|
||||
.replace("{tick}", tick)
|
||||
.replace("{subject}", subjectId.toString())
|
||||
).select(".mainContainer").first();
|
||||
|
||||
Element table = mainContainer.select("table:nth-of-type(2)").first();
|
||||
|
||||
Elements headerCells = table.select("thead th");
|
||||
List<Type> typeList = new ArrayList<>();
|
||||
|
||||
Elements typesRows = table.select("tbody tr");
|
||||
|
||||
// fill types with months
|
||||
for (Element row : typesRows) {
|
||||
Elements monthsCells = row.select("td");
|
||||
|
||||
List<Month> monthList = new ArrayList<>();
|
||||
|
||||
// iterate over month in type, first column is empty, last is `total`; (0, n-1)
|
||||
for (int i = 1; i < monthsCells.size() - 1; i++) {
|
||||
monthList.add(new Month()
|
||||
.setValue(NumberUtils.toInt(monthsCells.get(i).text(), 0))
|
||||
.setName(headerCells.get(i).text()));
|
||||
}
|
||||
|
||||
typeList.add(new Type()
|
||||
.setTotal(NumberUtils.toInt(monthsCells.last().text(), 0))
|
||||
.setName(monthsCells.get(0).text())
|
||||
.setMonthList(monthList));
|
||||
}
|
||||
|
||||
String total = mainContainer.select("h2").text().split(": ")[1];
|
||||
|
||||
return new Types()
|
||||
.setTotal(NumberUtils.toDouble(total.replace("%", "").replace(",", ".")))
|
||||
.setTypeList(typeList);
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class AttendanceTable {
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
private String attendancePageUrl = "Frekwencja.mvc?data=";
|
||||
|
||||
public AttendanceTable(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getWeekTable() throws IOException {
|
||||
return getWeekTable("");
|
||||
}
|
||||
|
||||
public Week getWeekTable(String tick) throws IOException {
|
||||
Element table = snp.getSnPPageDocument(attendancePageUrl + tick)
|
||||
.select(".mainContainer .presentData").first();
|
||||
|
||||
Elements headerCells = table.select("thead th");
|
||||
List<Day> days = new ArrayList<>();
|
||||
|
||||
for (int i = 1; i < headerCells.size(); i++) {
|
||||
days.add(new Day().setDate(headerCells.get(i).html().split("<br>")[1]));
|
||||
}
|
||||
|
||||
Elements hoursInDays = table.select("tbody tr");
|
||||
|
||||
// fill days in week with lessons
|
||||
for (Element row : hoursInDays) {
|
||||
Elements hours = row.select("td");
|
||||
|
||||
// fill hours in day
|
||||
int size = hours.size();
|
||||
for (int i = 1; i < size; i++) {
|
||||
days.get(i - 1).setLesson(getNewLesson(hours.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
String[] dayDescription = headerCells.get(1).html().split("<br>");
|
||||
|
||||
return new Week()
|
||||
.setStartDayDate(dayDescription[1])
|
||||
.setDays(days);
|
||||
}
|
||||
|
||||
private Lesson getNewLesson(Element cell) {
|
||||
Lesson lesson = new Lesson();
|
||||
lesson.setSubject(cell.select("span").text());
|
||||
|
||||
if (Lesson.CLASS_NOT_EXIST.equals(cell.attr("class"))) {
|
||||
lesson.setNotExist(true);
|
||||
lesson.setEmpty(true);
|
||||
|
||||
return lesson;
|
||||
}
|
||||
|
||||
switch (cell.select("div").attr("class")) {
|
||||
case Lesson.CLASS_PRESENCE:
|
||||
lesson.setPresence(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_UNEXCUSED:
|
||||
lesson.setAbsenceUnexcused(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_EXCUSED:
|
||||
lesson.setAbsenceExcused(true);
|
||||
break;
|
||||
case Lesson.CLASS_ABSENCE_FOR_SCHOOL_REASONS:
|
||||
lesson.setAbsenceForSchoolReasons(true);
|
||||
break;
|
||||
case Lesson.CLASS_UNEXCUSED_LATENESS:
|
||||
lesson.setUnexcusedLateness(true);
|
||||
break;
|
||||
case Lesson.CLASS_EXCUSED_LATENESS:
|
||||
lesson.setExcusedLateness(true);
|
||||
break;
|
||||
case Lesson.CLASS_EXEMPTION:
|
||||
lesson.setExemption(true);
|
||||
break;
|
||||
|
||||
default:
|
||||
lesson.setEmpty(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return lesson;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
public class Month {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private int value = 0;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Month setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Month setValue(int value) {
|
||||
this.value = value;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
public class Subject {
|
||||
|
||||
private int id = -1;
|
||||
|
||||
private String name = "";
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Subject setId(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Subject setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Type {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private int total = 0;
|
||||
|
||||
private List<Month> monthList = new ArrayList<>();
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Type setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public Type setTotal(int total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Month> getMonthList() {
|
||||
return monthList;
|
||||
}
|
||||
|
||||
public Type setMonthList(List<Month> monthList) {
|
||||
this.monthList = monthList;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package io.github.wulkanowy.api.attendance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Types {
|
||||
|
||||
private double total = 0;
|
||||
|
||||
private List<Type> typeList = new ArrayList<>();
|
||||
|
||||
public double getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
public Types setTotal(double total) {
|
||||
this.total = total;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Type> getTypeList() {
|
||||
return typeList;
|
||||
}
|
||||
|
||||
public Types setTypeList(List<Type> typeList) {
|
||||
this.typeList = typeList;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package io.github.wulkanowy.api.exams;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class 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) {
|
||||
this.examList.add(exam);
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package io.github.wulkanowy.api.exams;
|
||||
|
||||
public class Exam {
|
||||
|
||||
private String subjectAndGroup = "";
|
||||
|
||||
private String type = "";
|
||||
|
||||
private String description = "";
|
||||
|
||||
private String teacher = "";
|
||||
|
||||
private String entryDate = "";
|
||||
|
||||
public String getSubjectAndGroup() {
|
||||
return subjectAndGroup;
|
||||
}
|
||||
|
||||
public Exam setSubjectAndGroup(String subjectAndGroup) {
|
||||
this.subjectAndGroup = subjectAndGroup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Exam setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Exam setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTeacher() {
|
||||
return teacher;
|
||||
}
|
||||
|
||||
public Exam setTeacher(String teacher) {
|
||||
this.teacher = teacher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntryDate() {
|
||||
return entryDate;
|
||||
}
|
||||
|
||||
public Exam setEntryDate(String entryDate) {
|
||||
this.entryDate = entryDate;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package io.github.wulkanowy.api.exams;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class ExamsWeek {
|
||||
|
||||
private final StudentAndParent snp;
|
||||
|
||||
private final String examsPageUrl = "Sprawdziany.mvc/Terminarz?rodzajWidoku=2&data=";
|
||||
|
||||
public ExamsWeek(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getCurrent() throws IOException {
|
||||
return getWeek("", true);
|
||||
}
|
||||
|
||||
public Week getWeek(String tick, final boolean onlyNotEmpty) throws IOException {
|
||||
Document examsPage = snp.getSnPPageDocument(examsPageUrl + tick);
|
||||
Elements examsDays = examsPage.select(".mainContainer > div:not(.navigation)");
|
||||
|
||||
List<Day> days = new ArrayList<>();
|
||||
|
||||
for (Element item : examsDays) {
|
||||
Day day = new Day();
|
||||
Element dayHeading = item.select("h2").first();
|
||||
|
||||
if (null == dayHeading && onlyNotEmpty) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null != dayHeading) {
|
||||
day = new Day().setDate(dayHeading.text().split(", ")[1]);
|
||||
}
|
||||
|
||||
Elements exams = item.select("article");
|
||||
for (Element e : exams) {
|
||||
day.addExam(new Exam()
|
||||
.setSubjectAndGroup(snp.getRowDataChildValue(e, 1))
|
||||
.setType(snp.getRowDataChildValue(e, 2))
|
||||
.setDescription(snp.getRowDataChildValue(e, 3))
|
||||
.setTeacher(snp.getRowDataChildValue(e, 4).split(", ")[0])
|
||||
.setEntryDate(snp.getRowDataChildValue(e, 4).split(", ")[1])
|
||||
);
|
||||
}
|
||||
|
||||
days.add(day);
|
||||
}
|
||||
|
||||
Week week = new Week();
|
||||
week.setStartDate(examsDays.select("h2").first().text().split(" ")[1]);
|
||||
week.setDayList(days);
|
||||
|
||||
return week;
|
||||
}
|
||||
}
|
@ -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,112 +0,0 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
public class Grade {
|
||||
|
||||
protected String value = "";
|
||||
|
||||
private String subject = "";
|
||||
|
||||
private String color = "";
|
||||
|
||||
private String symbol = "";
|
||||
|
||||
private String description = "";
|
||||
|
||||
private String weight = "";
|
||||
|
||||
private String date = "";
|
||||
|
||||
private String teacher = "";
|
||||
|
||||
private String semester = "";
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public Grade setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Grade setValue(String value) {
|
||||
this.value = value;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public Grade setColor(String color) {
|
||||
this.color = color;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSymbol() {
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public Grade setSymbol(String symbol) {
|
||||
this.symbol = symbol;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Grade setDescription(String description) {
|
||||
this.description = description;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public Grade setWeight(String weight) {
|
||||
this.weight = weight;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Grade setDate(String date) {
|
||||
this.date = date;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTeacher() {
|
||||
return teacher;
|
||||
}
|
||||
|
||||
public Grade setTeacher(String teacher) {
|
||||
this.teacher = teacher;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSemester() {
|
||||
return semester;
|
||||
}
|
||||
|
||||
public Grade setSemester(String semester) {
|
||||
this.semester = semester;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.github.wulkanowy.api.Semester;
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
|
||||
public class GradesList {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private String gradesPageUrl = "Oceny/Wszystkie?details=2&okres=";
|
||||
|
||||
private List<Grade> grades = new ArrayList<>();
|
||||
|
||||
public GradesList(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public String getGradesPageUrl() {
|
||||
return gradesPageUrl;
|
||||
}
|
||||
|
||||
public List<Grade> getAll() throws IOException, LoginErrorException, ParseException {
|
||||
return getAll("");
|
||||
}
|
||||
|
||||
public List<Grade> getAll(String semester) throws IOException, ParseException {
|
||||
Document gradesPage = snp.getSnPPageDocument(getGradesPageUrl() + semester);
|
||||
Elements gradesRows = gradesPage.select(".ocenySzczegoly-table > tbody > tr");
|
||||
Semester currentSemester = snp.getCurrentSemester(snp.getSemesters(gradesPage));
|
||||
|
||||
for (Element row : gradesRows) {
|
||||
if ("Brak ocen".equals(row.select("td:nth-child(2)").text())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String descriptions = row.select("td:nth-child(3)").text();
|
||||
String symbol = descriptions.split(", ")[0];
|
||||
String description = descriptions.replaceFirst(symbol, "").replaceFirst(", ", "");
|
||||
|
||||
Pattern pattern = Pattern.compile("#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})");
|
||||
Matcher matcher = pattern.matcher(row.select("td:nth-child(2) span.ocenaCzastkowa")
|
||||
.attr("style"));
|
||||
|
||||
String color = "";
|
||||
while (matcher.find()) {
|
||||
color = matcher.group(1);
|
||||
}
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy", Locale.ROOT);
|
||||
Date d = sdf.parse(row.select("td:nth-child(5)").text());
|
||||
sdf.applyPattern("yyyy-MM-dd");
|
||||
|
||||
grades.add(new Grade()
|
||||
.setSubject(row.select("td:nth-child(1)").text())
|
||||
.setValue(row.select("td:nth-child(2)").text())
|
||||
.setColor(color)
|
||||
.setSymbol(symbol)
|
||||
.setDescription(description)
|
||||
.setWeight(row.select("td:nth-child(4)").text())
|
||||
.setDate(sdf.format(d))
|
||||
.setTeacher(row.select("td:nth-child(6)").text())
|
||||
.setSemester(currentSemester.getNumber())
|
||||
);
|
||||
}
|
||||
|
||||
return grades;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
public class Subject {
|
||||
|
||||
private String name;
|
||||
|
||||
private String predictedRating;
|
||||
|
||||
private String finalRating;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Subject setName(String name) {
|
||||
this.name = name;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPredictedRating() {
|
||||
return predictedRating;
|
||||
}
|
||||
|
||||
public Subject setPredictedRating(String predictedRating) {
|
||||
this.predictedRating = predictedRating;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFinalRating() {
|
||||
return finalRating;
|
||||
}
|
||||
|
||||
public Subject setFinalRating(String finalRating) {
|
||||
this.finalRating = finalRating;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package io.github.wulkanowy.api.grades;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class SubjectsList {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private String subjectsPageUrl = "Oceny/Wszystkie?details=1";
|
||||
|
||||
public SubjectsList(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public List<Subject> getAll() throws IOException {
|
||||
Document subjectPage = snp.getSnPPageDocument(subjectsPageUrl);
|
||||
|
||||
Elements rows = subjectPage.select(".ocenyZwykle-table > tbody > tr");
|
||||
|
||||
List<Subject> subjects = new ArrayList<>();
|
||||
|
||||
for (Element subjectRow : rows) {
|
||||
subjects.add(new Subject()
|
||||
.setName(subjectRow.select("td:nth-child(1)").text())
|
||||
.setPredictedRating(subjectRow.select("td:nth-last-child(2)").text())
|
||||
.setFinalRating(subjectRow.select("td:nth-last-child(1)").text())
|
||||
);
|
||||
}
|
||||
|
||||
return subjects;
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
public class AccountPermissionException extends Exception {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
public class BadCredentialsException extends Exception {
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.parser.Parser;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.github.wulkanowy.api.Api;
|
||||
import io.github.wulkanowy.api.Cookies;
|
||||
|
||||
public class Login extends Api {
|
||||
|
||||
private String loginPageUrl = "https://cufs.vulcan.net.pl/{symbol}/Account/LogOn" +
|
||||
"?ReturnUrl=%2F{symbol}%2FFS%2FLS%3Fwa%3Dwsignin1.0%26wtrealm%3D" +
|
||||
"https%253a%252f%252fuonetplus.vulcan.net.pl%252f{symbol}%252fLoginEndpoint.aspx%26wctx%3D" +
|
||||
"https%253a%252f%252fuonetplus.vulcan.net.pl%252f{symbol}%252fLoginEndpoint.aspx";
|
||||
|
||||
private String loginEndpointPageUrl =
|
||||
"https://uonetplus.vulcan.net.pl/{symbol}/LoginEndpoint.aspx";
|
||||
|
||||
public Login(Cookies cookies) {
|
||||
this.cookies = cookies;
|
||||
}
|
||||
|
||||
public String getLoginPageUrl() {
|
||||
return loginPageUrl;
|
||||
}
|
||||
|
||||
public String getLoginEndpointPageUrl() {
|
||||
return loginEndpointPageUrl;
|
||||
}
|
||||
|
||||
public String login(String email, String password, String symbol)
|
||||
throws BadCredentialsException, LoginErrorException, AccountPermissionException, IOException {
|
||||
String certificate = sendCredentials(email, password, symbol);
|
||||
|
||||
return sendCertificate(certificate, symbol);
|
||||
}
|
||||
|
||||
public String sendCredentials(String email, String password, String symbol)
|
||||
throws IOException, BadCredentialsException {
|
||||
loginPageUrl = getLoginPageUrl().replace("{symbol}", symbol);
|
||||
|
||||
Document html = postPageByUrl(loginPageUrl, new String[][]{
|
||||
{"LoginName", email},
|
||||
{"Password", password}
|
||||
});
|
||||
|
||||
if (null != html.select(".ErrorMessage").first()) {
|
||||
throw new BadCredentialsException();
|
||||
}
|
||||
|
||||
return html.select("input[name=wresult]").attr("value");
|
||||
}
|
||||
|
||||
public String sendCertificate(String certificate, String defaultSymbol)
|
||||
throws IOException, LoginErrorException, AccountPermissionException {
|
||||
String symbol = findSymbol(defaultSymbol, certificate);
|
||||
|
||||
loginEndpointPageUrl = getLoginEndpointPageUrl()
|
||||
.replace("{symbol}", symbol);
|
||||
|
||||
Document html = postPageByUrl(loginEndpointPageUrl, new String[][]{
|
||||
{"wa", "wsignin1.0"},
|
||||
{"wresult", certificate}
|
||||
});
|
||||
|
||||
if (html.getElementsByTag("title").text().equals("Logowanie")) {
|
||||
throw new AccountPermissionException();
|
||||
}
|
||||
|
||||
if (!html.select("title").text().equals("Uonet+")) {
|
||||
throw new LoginErrorException();
|
||||
}
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public String findSymbol(String symbol, String certificate) {
|
||||
if ("Default".equals(symbol)) {
|
||||
return findSymbolInCertificate(certificate);
|
||||
}
|
||||
|
||||
return symbol;
|
||||
}
|
||||
|
||||
public String findSymbolInCertificate(String certificate) {
|
||||
Elements els = Jsoup.parse(certificate.replaceAll(":", ""), "", Parser.xmlParser())
|
||||
.select("[AttributeName=\"UserInstance\"] samlAttributeValue");
|
||||
|
||||
if (0 == els.size()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return els.get(1).text();
|
||||
}
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
public class LoginErrorException extends NotLoggedInErrorException {
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package io.github.wulkanowy.api.login;
|
||||
|
||||
|
||||
public class NotLoggedInErrorException extends Exception {
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package io.github.wulkanowy.api.notes;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class AchievementsList {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private List<String> achievementsList = new ArrayList<>();
|
||||
|
||||
private String notesPageUrl = "UwagiOsiagniecia.mvc/Wszystkie";
|
||||
|
||||
public AchievementsList(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public List<String> getAllAchievements() throws IOException {
|
||||
Element pageFragment = snp.getSnPPageDocument(notesPageUrl)
|
||||
.select(".mainContainer > div").get(1);
|
||||
Elements items = pageFragment.select("article");
|
||||
|
||||
for (Element item : items) {
|
||||
achievementsList.add(item.text());
|
||||
}
|
||||
|
||||
return achievementsList;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package io.github.wulkanowy.api.notes;
|
||||
|
||||
public class Note {
|
||||
|
||||
private String date;
|
||||
|
||||
private String teacher;
|
||||
|
||||
private String category;
|
||||
|
||||
private String content;
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Note setDate(String date) {
|
||||
this.date = date;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTeacher() {
|
||||
return teacher;
|
||||
}
|
||||
|
||||
public Note setTeacher(String teacher) {
|
||||
this.teacher = teacher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public Note setCategory(String category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public Note setContent(String content) {
|
||||
this.content = content;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package io.github.wulkanowy.api.notes;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class NotesList {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private List<Note> notesList = new ArrayList<>();
|
||||
|
||||
private String notesPageUrl = "UwagiOsiagniecia.mvc/Wszystkie";
|
||||
|
||||
public NotesList(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public List<Note> getAllNotes() throws IOException {
|
||||
Element pageFragment = snp.getSnPPageDocument(notesPageUrl)
|
||||
.select(".mainContainer > div").get(0);
|
||||
Elements items = pageFragment.select("article");
|
||||
Elements dates = pageFragment.select("h2");
|
||||
|
||||
int index = 0;
|
||||
for (Element item : items) {
|
||||
notesList.add(new Note()
|
||||
.setDate(dates.get(index++).text())
|
||||
.setTeacher(snp.getRowDataChildValue(item, 1))
|
||||
.setCategory(snp.getRowDataChildValue(item, 2))
|
||||
.setContent(snp.getRowDataChildValue(item, 3))
|
||||
);
|
||||
}
|
||||
|
||||
return notesList;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
public class SchoolData {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private String address = "";
|
||||
|
||||
private String phoneNumber = "";
|
||||
|
||||
private String headmaster = "";
|
||||
|
||||
private String[] pedagogue;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public SchoolData setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public SchoolData setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public SchoolData setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getHeadmaster() {
|
||||
return headmaster;
|
||||
}
|
||||
|
||||
public SchoolData setHeadmaster(String headmaster) {
|
||||
this.headmaster = headmaster;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getPedagogues() {
|
||||
return pedagogue;
|
||||
}
|
||||
|
||||
public SchoolData setPedagogue(String[] pedagogue) {
|
||||
this.pedagogue = pedagogue;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class SchoolInfo {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private String schoolPageUrl = "Szkola.mvc/Nauczyciele";
|
||||
|
||||
public SchoolInfo(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public SchoolData getSchoolData() throws IOException {
|
||||
Element e = snp.getSnPPageDocument(schoolPageUrl)
|
||||
.select(".mainContainer > article").get(0);
|
||||
|
||||
return new SchoolData()
|
||||
.setName(snp.getRowDataChildValue(e, 1))
|
||||
.setAddress(snp.getRowDataChildValue(e, 2))
|
||||
.setPhoneNumber(snp.getRowDataChildValue(e, 3))
|
||||
.setHeadmaster(snp.getRowDataChildValue(e, 4))
|
||||
.setPedagogue(snp.getRowDataChildValue(e, 5).split(", "));
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
public class Subject {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private String[] teachers;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Subject setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getTeachers() {
|
||||
return teachers;
|
||||
}
|
||||
|
||||
public Subject setTeachers(String[] teachers) {
|
||||
this.teachers = teachers;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TeachersData {
|
||||
|
||||
private String className = "";
|
||||
|
||||
private String[] classTeacher;
|
||||
|
||||
private List<Subject> subjects;
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public TeachersData setClassName(String className) {
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getClassTeacher() {
|
||||
return classTeacher;
|
||||
}
|
||||
|
||||
public TeachersData setClassTeacher(String[] classTeacher) {
|
||||
this.classTeacher = classTeacher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<Subject> getSubjects() {
|
||||
return subjects;
|
||||
}
|
||||
|
||||
public TeachersData setSubjects(List<Subject> subjects) {
|
||||
this.subjects = subjects;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package io.github.wulkanowy.api.school;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class TeachersInfo {
|
||||
|
||||
private StudentAndParent snp = null;
|
||||
|
||||
private String schoolPageUrl = "Szkola.mvc/Nauczyciele";
|
||||
|
||||
public TeachersInfo(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public TeachersData getTeachersData() throws IOException {
|
||||
Document doc = snp.getSnPPageDocument(schoolPageUrl);
|
||||
Elements rows = doc.select(".mainContainer > table tbody tr");
|
||||
String description = doc.select(".mainContainer > p").first().text();
|
||||
|
||||
List<Subject> subjects = new ArrayList<>();
|
||||
|
||||
for (Element subject : rows) {
|
||||
subjects.add(new Subject()
|
||||
.setName(subject.select("td").get(1).text())
|
||||
.setTeachers(subject.select("td").get(2).text().split(", "))
|
||||
);
|
||||
}
|
||||
|
||||
return new TeachersData()
|
||||
.setClassName(description.split(", ")[0].split(": ")[1].trim())
|
||||
.setClassTeacher(description.split("Wychowawcy:")[1].trim().split(", "))
|
||||
.setSubjects(subjects);
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Day {
|
||||
|
||||
private List<Lesson> lessons = new ArrayList<>();
|
||||
|
||||
private String date = "";
|
||||
|
||||
private boolean isFreeDay = false;
|
||||
|
||||
private String freeDayName = "";
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public boolean isFreeDay() {
|
||||
return isFreeDay;
|
||||
}
|
||||
|
||||
public Day setFreeDay(boolean freeDay) {
|
||||
isFreeDay = freeDay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFreeDayName() {
|
||||
return freeDayName;
|
||||
}
|
||||
|
||||
public Day setFreeDayName(String freeDayName) {
|
||||
this.freeDayName = freeDayName;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,155 +0,0 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
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 subject = "";
|
||||
|
||||
private String teacher = "";
|
||||
|
||||
private String room = "";
|
||||
|
||||
private String description = "";
|
||||
|
||||
private String groupName = "";
|
||||
|
||||
private String startTime = "";
|
||||
|
||||
private String endTime = "";
|
||||
|
||||
private boolean isEmpty = false;
|
||||
|
||||
private boolean isDivisionIntoGroups = false;
|
||||
|
||||
private boolean isPlanning = false;
|
||||
|
||||
private boolean isRealized = false;
|
||||
|
||||
private boolean isMovedOrCanceled = false;
|
||||
|
||||
private boolean isNewMovedInOrChanged = false;
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public Lesson setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTeacher() {
|
||||
return teacher;
|
||||
}
|
||||
|
||||
public Lesson setTeacher(String teacher) {
|
||||
this.teacher = teacher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
public Lesson setRoom(String room) {
|
||||
this.room = room;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Lesson setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public Lesson setGroupName(String groupName) {
|
||||
this.groupName = groupName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Lesson setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public Lesson setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return isEmpty;
|
||||
}
|
||||
|
||||
public Lesson setEmpty(boolean empty) {
|
||||
isEmpty = empty;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isDivisionIntoGroups() {
|
||||
return isDivisionIntoGroups;
|
||||
}
|
||||
|
||||
public Lesson setDivisionIntoGroups(boolean divisionIntoGroups) {
|
||||
isDivisionIntoGroups = divisionIntoGroups;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPlanning() {
|
||||
return isPlanning;
|
||||
}
|
||||
|
||||
public Lesson setPlanning(boolean planning) {
|
||||
isPlanning = planning;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isRealized() {
|
||||
return isRealized;
|
||||
}
|
||||
|
||||
public Lesson setRealized(boolean realized) {
|
||||
isRealized = realized;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMovedOrCanceled() {
|
||||
return isMovedOrCanceled;
|
||||
}
|
||||
|
||||
public Lesson setMovedOrCanceled(boolean movedOrCanceled) {
|
||||
isMovedOrCanceled = movedOrCanceled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNewMovedInOrChanged() {
|
||||
return isNewMovedInOrChanged;
|
||||
}
|
||||
|
||||
public Lesson setNewMovedInOrChanged(boolean newMovedInOrChanged) {
|
||||
isNewMovedInOrChanged = newMovedInOrChanged;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
|
||||
public class Timetable {
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
private String timetablePageUrl = "Lekcja.mvc/PlanLekcji?data=";
|
||||
|
||||
public Timetable(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Week getWeekTable() throws IOException, LoginErrorException {
|
||||
return getWeekTable("");
|
||||
}
|
||||
|
||||
public Week getWeekTable(String tick) throws IOException {
|
||||
Element table = snp.getSnPPageDocument(timetablePageUrl + tick)
|
||||
.select(".mainContainer .presentData").first();
|
||||
|
||||
Elements tableHeaderCells = table.select("thead th");
|
||||
List<Day> days = new ArrayList<>();
|
||||
|
||||
for (int i = 2; i < 7; i++) {
|
||||
String[] dayHeaderCell = tableHeaderCells.get(i).html().split("<br>");
|
||||
boolean isFreeDay = tableHeaderCells.get(i).hasClass("free-day");
|
||||
|
||||
Day day = new Day();
|
||||
day.setDate(dayHeaderCell[1]);
|
||||
|
||||
if (isFreeDay) {
|
||||
day.setFreeDay(isFreeDay);
|
||||
day.setFreeDayName(dayHeaderCell[2]);
|
||||
}
|
||||
|
||||
days.add(day);
|
||||
}
|
||||
|
||||
Elements hoursInDays = table.select("tbody tr");
|
||||
|
||||
// fill days in week with lessons
|
||||
for (Element row : hoursInDays) {
|
||||
Elements hours = row.select("td");
|
||||
|
||||
// fill hours in day
|
||||
for (int i = 2; i < hours.size(); i++) {
|
||||
Lesson lesson = new Lesson();
|
||||
|
||||
Elements e = hours.get(i).select("div");
|
||||
switch (e.size()) {
|
||||
case 1:
|
||||
lesson = getLessonFromElement(e.first());
|
||||
break;
|
||||
case 3:
|
||||
lesson = getLessonFromElement(e.get(1));
|
||||
break;
|
||||
default:
|
||||
lesson.setEmpty(true);
|
||||
break;
|
||||
}
|
||||
|
||||
String[] startEndEnd = hours.get(1).text().split(" ");
|
||||
lesson.setStartTime(startEndEnd[0]);
|
||||
lesson.setEndTime(startEndEnd[1]);
|
||||
|
||||
days.get(i - 2).setLesson(lesson);
|
||||
}
|
||||
}
|
||||
|
||||
Element startDayCellHeader = tableHeaderCells.get(2);
|
||||
String[] dayDescription = startDayCellHeader.html().split("<br>");
|
||||
|
||||
return new Week()
|
||||
.setStartDayDate(dayDescription[1])
|
||||
.setDays(days);
|
||||
}
|
||||
|
||||
private Lesson getLessonFromElement(Element e) {
|
||||
Lesson lesson = new Lesson();
|
||||
Elements spans = e.select("span");
|
||||
|
||||
lesson.setSubject(spans.get(0).text());
|
||||
lesson.setTeacher(spans.get(1).text());
|
||||
lesson.setRoom(spans.get(2).text());
|
||||
|
||||
// okienko dla uczniów
|
||||
if (5 == spans.size()) {
|
||||
lesson.setTeacher(spans.get(2).text());
|
||||
lesson.setRoom(spans.get(3).text());
|
||||
}
|
||||
|
||||
lesson = getLessonGroupDivisionInfo(lesson, spans);
|
||||
lesson = getLessonTypeInfo(lesson, spans);
|
||||
lesson = getLessonDescriptionInfo(lesson, spans);
|
||||
|
||||
return lesson;
|
||||
}
|
||||
|
||||
private Lesson getLessonGroupDivisionInfo(Lesson lesson, Elements e) {
|
||||
if ((4 == e.size() && (e.first().attr("class").equals("")) ||
|
||||
(5 == e.size() && e.first().hasClass(Lesson.CLASS_NEW_MOVED_IN_OR_CHANGED)))) {
|
||||
lesson.setDivisionIntoGroups(true);
|
||||
String[] subjectNameArray = lesson.getSubject().split(" ");
|
||||
String groupName = subjectNameArray[subjectNameArray.length - 1];
|
||||
lesson.setSubject(lesson.getSubject().replace(" " + groupName, ""));
|
||||
lesson.setGroupName(StringUtils.substringBetween(groupName, "[", "]"));
|
||||
lesson.setTeacher(e.get(2).text());
|
||||
lesson.setRoom(e.get(3).text());
|
||||
}
|
||||
|
||||
return lesson;
|
||||
}
|
||||
|
||||
private Lesson getLessonTypeInfo(Lesson lesson, Elements e) {
|
||||
if (e.first().hasClass(Lesson.CLASS_MOVED_OR_CANCELED)) {
|
||||
lesson.setMovedOrCanceled(true);
|
||||
} else if (e.first().hasClass(Lesson.CLASS_NEW_MOVED_IN_OR_CHANGED)) {
|
||||
lesson.setNewMovedInOrChanged(true);
|
||||
} else if (e.first().hasClass(Lesson.CLASS_PLANNING)) {
|
||||
lesson.setPlanning(true);
|
||||
}
|
||||
|
||||
if (e.last().hasClass(Lesson.CLASS_REALIZED)
|
||||
|| e.first().attr("class").equals("")) {
|
||||
lesson.setRealized(true);
|
||||
}
|
||||
|
||||
return lesson;
|
||||
}
|
||||
|
||||
private Lesson getLessonDescriptionInfo(Lesson lesson, Elements e) {
|
||||
if ((4 == e.size() || 5 == e.size())
|
||||
&& (e.first().hasClass(Lesson.CLASS_MOVED_OR_CANCELED)
|
||||
|| e.first().hasClass(Lesson.CLASS_NEW_MOVED_IN_OR_CHANGED))) {
|
||||
lesson.setDescription(StringUtils.substringBetween(e.last().text(), "(", ")"));
|
||||
}
|
||||
|
||||
return lesson;
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package io.github.wulkanowy.api.timetable;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
public class AddressData {
|
||||
|
||||
private String address = "";
|
||||
|
||||
private String registeredAddress = "";
|
||||
|
||||
private String correspondenceAddress = "";
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public AddressData setAddress(String address) {
|
||||
this.address = address;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getRegisteredAddress() {
|
||||
return registeredAddress;
|
||||
}
|
||||
|
||||
public AddressData setRegisteredAddress(String registeredAddress) {
|
||||
this.registeredAddress = registeredAddress;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCorrespondenceAddress() {
|
||||
return correspondenceAddress;
|
||||
}
|
||||
|
||||
public AddressData setCorrespondenceAddress(String correspondenceAddress) {
|
||||
this.correspondenceAddress = correspondenceAddress;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
import io.github.wulkanowy.api.login.LoginErrorException;
|
||||
|
||||
public class BasicInformation {
|
||||
|
||||
private static Document studentDataPageDocument;
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
private String studentDataPageUrl = "Uczen.mvc/DanePodstawowe";
|
||||
|
||||
public BasicInformation(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public Document getStudentDataPageDocument() throws IOException {
|
||||
if (null == studentDataPageDocument) {
|
||||
studentDataPageDocument = snp.getSnPPageDocument(studentDataPageUrl);
|
||||
}
|
||||
|
||||
return studentDataPageDocument;
|
||||
}
|
||||
|
||||
public PersonalData getPersonalData() throws IOException, LoginErrorException {
|
||||
Element e = getStudentDataPageDocument().select(".mainContainer > article").get(0);
|
||||
|
||||
String name = snp.getRowDataChildValue(e, 1);
|
||||
String[] names = name.split(" ");
|
||||
|
||||
return new PersonalData()
|
||||
.setName(name)
|
||||
.setFirstName(names[0])
|
||||
.setSurname(names[names.length - 1])
|
||||
.setFirstAndLastName(names[0] + " " + names[names.length - 1])
|
||||
.setDateAndBirthPlace(snp.getRowDataChildValue(e, 2))
|
||||
.setPesel(snp.getRowDataChildValue(e, 3))
|
||||
.setGender(snp.getRowDataChildValue(e, 4))
|
||||
.setPolishCitizenship("Tak".equals(snp.getRowDataChildValue(e, 5)))
|
||||
.setFamilyName(snp.getRowDataChildValue(e, 6))
|
||||
.setParentsNames(snp.getRowDataChildValue(e, 7));
|
||||
}
|
||||
|
||||
public AddressData getAddressData() throws IOException, LoginErrorException {
|
||||
Element e = getStudentDataPageDocument().select(".mainContainer > article").get(1);
|
||||
|
||||
return new AddressData()
|
||||
.setAddress(snp.getRowDataChildValue(e, 1))
|
||||
.setRegisteredAddress(snp.getRowDataChildValue(e, 2))
|
||||
.setCorrespondenceAddress(snp.getRowDataChildValue(e, 3));
|
||||
|
||||
}
|
||||
|
||||
public ContactDetails getContactDetails() throws IOException, LoginErrorException {
|
||||
Element e = getStudentDataPageDocument().select(".mainContainer > article").get(2);
|
||||
|
||||
return new ContactDetails()
|
||||
.setPhoneNumber(snp.getRowDataChildValue(e, 1))
|
||||
.setCellPhoneNumber(snp.getRowDataChildValue(e, 2))
|
||||
.setEmail(snp.getRowDataChildValue(e, 3));
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
public class ContactDetails {
|
||||
|
||||
private String phoneNumber = "";
|
||||
|
||||
private String cellPhoneNumber = "";
|
||||
|
||||
private String email = "";
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public ContactDetails setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getCellPhoneNumber() {
|
||||
return cellPhoneNumber;
|
||||
}
|
||||
|
||||
public ContactDetails setCellPhoneNumber(String cellPhoneNumber) {
|
||||
this.cellPhoneNumber = cellPhoneNumber;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public ContactDetails setEmail(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.github.wulkanowy.api.StudentAndParent;
|
||||
|
||||
public class FamilyInformation {
|
||||
|
||||
private StudentAndParent snp;
|
||||
|
||||
private String studentDataPageUrl = "Uczen.mvc/DanePodstawowe";
|
||||
|
||||
public FamilyInformation(StudentAndParent snp) {
|
||||
this.snp = snp;
|
||||
}
|
||||
|
||||
public List<FamilyMember> getFamilyMembers() throws IOException {
|
||||
Elements membersElements = snp.getSnPPageDocument(studentDataPageUrl)
|
||||
.select(".mainContainer > article:nth-of-type(n+4)");
|
||||
|
||||
List<FamilyMember> familyMembers = new ArrayList<>();
|
||||
|
||||
for (Element e : membersElements) {
|
||||
familyMembers.add(new FamilyMember()
|
||||
.setName(snp.getRowDataChildValue(e, 1))
|
||||
.setKinship(snp.getRowDataChildValue(e, 2))
|
||||
.setAddress(snp.getRowDataChildValue(e, 3))
|
||||
.setTelephones(snp.getRowDataChildValue(e, 4))
|
||||
.setEmail(snp.getRowDataChildValue(e, 5))
|
||||
);
|
||||
}
|
||||
|
||||
return familyMembers;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
public class FamilyMember {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private String kinship = "";
|
||||
|
||||
private String address = "";
|
||||
|
||||
private String telephones = "";
|
||||
|
||||
private String email = "";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public FamilyMember setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getKinship() {
|
||||
return kinship;
|
||||
}
|
||||
|
||||
public FamilyMember setKinship(String kinship) {
|
||||
this.kinship = kinship;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public FamilyMember setAddress(String address) {
|
||||
this.address = address;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTelephones() {
|
||||
return telephones;
|
||||
}
|
||||
|
||||
public FamilyMember setTelephones(String telephones) {
|
||||
this.telephones = telephones;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public FamilyMember setEmail(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -1,114 +0,0 @@
|
||||
package io.github.wulkanowy.api.user;
|
||||
|
||||
public class PersonalData {
|
||||
|
||||
private String name = "";
|
||||
|
||||
private String firstName = "";
|
||||
|
||||
private String surname = "";
|
||||
|
||||
private String firstAndLastName = "";
|
||||
|
||||
private String dateAndBirthPlace = "";
|
||||
|
||||
private String pesel = "";
|
||||
|
||||
private String gender = "";
|
||||
|
||||
private boolean isPolishCitizenship;
|
||||
|
||||
private String familyName = "";
|
||||
|
||||
private String parentsNames = "";
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public PersonalData setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public PersonalData setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public PersonalData setSurname(String surname) {
|
||||
this.surname = surname;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFirstAndLastName() {
|
||||
return firstAndLastName;
|
||||
}
|
||||
|
||||
public PersonalData setFirstAndLastName(String firstAndLastName) {
|
||||
this.firstAndLastName = firstAndLastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDateAndBirthPlace() {
|
||||
return dateAndBirthPlace;
|
||||
}
|
||||
|
||||
public PersonalData setDateAndBirthPlace(String dateAndBirthPlace) {
|
||||
this.dateAndBirthPlace = dateAndBirthPlace;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPesel() {
|
||||
return pesel;
|
||||
}
|
||||
|
||||
public PersonalData setPesel(String pesel) {
|
||||
this.pesel = pesel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public PersonalData setGender(String gender) {
|
||||
this.gender = gender;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isPolishCitizenship() {
|
||||
return isPolishCitizenship;
|
||||
}
|
||||
|
||||
public PersonalData setPolishCitizenship(boolean polishCitizenship) {
|
||||
isPolishCitizenship = polishCitizenship;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFamilyName() {
|
||||
return familyName;
|
||||
}
|
||||
|
||||
public PersonalData setFamilyName(String familyName) {
|
||||
this.familyName = familyName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParentsNames() {
|
||||
return parentsNames;
|
||||
}
|
||||
|
||||
public PersonalData setParentsNames(String parentsNames) {
|
||||
this.parentsNames = parentsNames;
|
||||
return this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user