1
0

API improvements (#13)

This commit is contained in:
Mikołaj Pich
2017-08-07 08:24:45 +02:00
committed by RicomenPL
parent 3d6515bcf2
commit 0ea13cdadd
41 changed files with 829 additions and 405 deletions

View File

@ -19,7 +19,6 @@ import java.util.Map;
import io.github.wulkanowy.R;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.grades.Grades;
import io.github.wulkanowy.api.grades.GradesList;
import io.github.wulkanowy.api.grades.Subject;
import io.github.wulkanowy.api.grades.SubjectsList;
@ -93,8 +92,8 @@ public class MarksFragment extends Fragment {
Account account = accountsDatabase.getAccount(mContext.getSharedPreferences("LoginData", mContext.MODE_PRIVATE).getLong("isLogin", 0));
accountsDatabase.close();
StudentAndParent snp = new StudentAndParent(cookies, account.getCounty()).setUp();
SubjectsList subjectsList = new SubjectsList(snp.getCookiesObject(), snp);
StudentAndParent snp = new StudentAndParent(cookies, account.getCounty());
SubjectsList subjectsList = new SubjectsList(snp);
SubjectsDatabase subjectsDatabase = new SubjectsDatabase(mContext);
subjectsDatabase.open();
@ -106,8 +105,7 @@ public class MarksFragment extends Fragment {
subjectsName.add(subject.getName());
}
Grades gradesObject = new Grades(snp.getCookiesObject(), snp);
GradesList gradesList = new GradesList(gradesObject, snp);
GradesList gradesList = new GradesList(snp);
GradesDatabase gradesDatabase = new GradesDatabase(mContext);
gradesDatabase.open();
gradesDatabase.put(gradesList.getAll());

View File

@ -22,7 +22,6 @@ import io.github.wulkanowy.api.login.Login;
import io.github.wulkanowy.api.login.LoginErrorException;
import io.github.wulkanowy.api.user.BasicInformation;
import io.github.wulkanowy.api.user.PersonalData;
import io.github.wulkanowy.api.user.User;
import io.github.wulkanowy.database.accounts.Account;
import io.github.wulkanowy.database.accounts.AccountsDatabase;
import io.github.wulkanowy.security.CryptoException;
@ -80,9 +79,8 @@ public class LoginTask extends AsyncTask<String, Integer, Integer> {
if (save) {
try {
StudentAndParent snp = new StudentAndParent(login.getCookiesObject(),
credentials[2]).setUp();
User user = new User(snp.getCookiesObject(), snp);
BasicInformation userInfo = new BasicInformation(user, snp);
credentials[2]);
BasicInformation userInfo = new BasicInformation(snp);
PersonalData personalData = userInfo.getPersonalData();
String firstAndLastName = personalData.getFirstAndLastName();

View File

@ -9,8 +9,6 @@ import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.github.wulkanowy.api.login.LoginErrorException;
@ -18,32 +16,22 @@ public class StudentAndParent extends Vulcan {
private String startPageUrl = "https://uonetplus.vulcan.net.pl/{locationID}/Start.mvc/Index";
private String gradesPageUrl = "https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/"
+ "Oceny/Wszystkie";
private String baseUrl = "https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/";
private String gradesPageUrl = baseUrl + "Oceny/Wszystkie";
private String locationID = "";
private String uonetPlusOpiekunUrl = "";
private String id = "";
public StudentAndParent(Cookies cookies, String locID) throws IOException {
public StudentAndParent(Cookies cookies, String locID) throws IOException, LoginErrorException {
this.cookies = cookies;
this.locationID = locID;
}
public String getGradesPageUrl() {
return gradesPageUrl;
}
public StudentAndParent setUp() throws IOException {
startPageUrl = startPageUrl.replace("{locationID}", locationID);
// get link to uonetplus-opiekun.vulcan.net.pl module
Document startPage = Jsoup.connect(startPageUrl)
.followRedirects(true)
.cookies(getCookies())
.get();
Document startPage = getPageByUrl(startPageUrl.replace("{locationID}", locationID));
Element studentTileLink = startPage.select(".panel.linkownia.pracownik.klient > a").first();
uonetPlusOpiekunUrl = studentTileLink.attr("href");
String uonetPlusOpiekunUrl = studentTileLink.attr("href");
//get context module cookie
Connection.Response res = Jsoup.connect(uonetPlusOpiekunUrl)
@ -53,39 +41,42 @@ public class StudentAndParent extends Vulcan {
cookies.addItems(res.cookies());
return this;
this.id = getCalculatedID(uonetPlusOpiekunUrl);
this.baseUrl = baseUrl
.replace("{locationID}", getLocationID())
.replace("{ID}", getID());
}
public String getLocationID() {
return locationID;
}
public String getID() throws LoginErrorException {
Pattern pattern = Pattern.compile("([0-9]{6})");
Matcher matcher = pattern.matcher(uonetPlusOpiekunUrl);
public String getID() {
return id;
}
// Finds all the matches until found by moving the `matcher` forward
if (!matcher.find()) {
public String getCalculatedID(String uonetPlusOpiekunUrl) throws LoginErrorException {
String[] path = uonetPlusOpiekunUrl.split("vulcan.net.pl/")[1].split("/");
if (4 != path.length) {
throw new LoginErrorException();
}
String match = matcher.group(1);
return match;
return path[1];
}
public String getRowDataChildValue(Element e, int index) {
return e.select(".daneWiersz .wartosc").get(index - 1).text();
Elements es = e.select(".daneWiersz .wartosc");
return es.get(index - 1).text();
}
public List<Semester> getSemesters() throws IOException, LoginErrorException {
String url = getGradesPageUrl();
url = url.replace("{locationID}", getLocationID());
url = url.replace("{ID}", getID());
public Document getSnPPageDocument(String url) throws IOException {
return getPageByUrl(baseUrl + url);
}
Document gradesPage = getPageByUrl(url);
return getSemesters(gradesPage);
public List<Semester> getSemesters() throws IOException {
return getSemesters(getSnPPageDocument(gradesPageUrl));
}
public List<Semester> getSemesters(Document gradesPage) {
@ -108,8 +99,7 @@ public class StudentAndParent extends Vulcan {
return semesters;
}
public Semester getCurrentSemester(List<Semester> semesterList)
throws IOException, LoginErrorException {
public Semester getCurrentSemester(List<Semester> semesterList) {
Semester current = null;
for (Semester s : semesterList) {
if (s.isCurrent()) {

View File

@ -1,28 +0,0 @@
package io.github.wulkanowy.api.grades;
import org.jsoup.nodes.Document;
import java.io.IOException;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class Grades extends Vulcan {
private StudentAndParent snp = null;
public Grades(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
this.snp = snp;
}
//TODO: move to snp
public Document getGradesPageDocument(String url) throws IOException, LoginErrorException {
return getPageByUrl(url
.replace("{locationID}", snp.getLocationID())
.replace("{ID}", snp.getID())
);
}
}

View File

@ -17,16 +17,13 @@ import io.github.wulkanowy.api.login.LoginErrorException;
public class GradesList extends Vulcan {
private Grades grades = null;
private StudentAndParent snp = null;
private String gradesPageUrl = "https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}"
+ "/Oceny/Wszystkie?details=2&okres=";
private String gradesPageUrl = "Oceny/Wszystkie?details=2&okres=";
private List<Grade> gradesList = new ArrayList<>();
private List<Grade> grades = new ArrayList<>();
public GradesList(Grades grades, StudentAndParent snp) {
this.grades = grades;
public GradesList(StudentAndParent snp) {
this.snp = snp;
}
@ -39,7 +36,7 @@ public class GradesList extends Vulcan {
}
public List<Grade> getAll(String semester) throws IOException, LoginErrorException {
Document gradesPage = grades.getGradesPageDocument(getGradesPageUrl() + semester);
Document gradesPage = snp.getSnPPageDocument(getGradesPageUrl() + semester);
Elements gradesRows = gradesPage.select(".ocenySzczegoly-table > tbody > tr");
Semester currentSemester = snp.getCurrentSemester(snp.getSemesters(gradesPage));
@ -57,7 +54,7 @@ public class GradesList extends Vulcan {
.attr("style"));
String color = matcher.find() ? matcher.group(1) : "";
gradesList.add(new Grade()
grades.add(new Grade()
.setSubject(row.select("td:nth-child(1)").text())
.setValue(row.select("td:nth-child(2)").text())
.setColor(color)
@ -70,6 +67,6 @@ public class GradesList extends Vulcan {
);
}
return gradesList;
return grades;
}
}

View File

@ -10,11 +10,11 @@ public class Subject {
private String finalRating;
public int getId(){
public int getId() {
return id;
}
public Subject setId(int id){
public Subject setId(int id) {
this.id = id;
return this;

View File

@ -8,7 +8,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
@ -17,29 +16,24 @@ public class SubjectsList extends Vulcan {
private StudentAndParent snp = null;
private String subjectsPageUrl =
"https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/Oceny/Wszystkie?details=1";
private String subjectsPageUrl = "Oceny/Wszystkie?details=1";
private List<Subject> subjects = new ArrayList<>();
public SubjectsList(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
public SubjectsList(StudentAndParent snp) {
this.snp = snp;
}
public List<Subject> getAll() throws IOException, LoginErrorException {
subjectsPageUrl = subjectsPageUrl.replace("{locationID}", snp.getLocationID());
subjectsPageUrl = subjectsPageUrl.replace("{ID}", snp.getID());
Document subjectPage = getPageByUrl(subjectsPageUrl);
Document subjectPage = snp.getSnPPageDocument(subjectsPageUrl);
Elements rows = subjectPage.select(".ocenyZwykle-table > tbody > tr");
for (Element subjectRow : rows) {
subjects.add(new Subject()
.setName(subjectRow.select("td:nth-child(1)").text())
.setPredictedRating(subjectRow.select("td:nth-child(3)").text())
.setFinalRating(subjectRow.select("td:nth-child(4)").text())
.setPredictedRating(subjectRow.select("td:nth-last-child(2)").text())
.setFinalRating(subjectRow.select("td:nth-last-child(1)").text())
);
}

View File

@ -13,11 +13,10 @@ public class Login extends Vulcan {
private String loginPageUrl = "https://cufs.vulcan.net.pl/{locationID}/Account/LogOn";
private String certificatePageUrl =
"https://cufs.vulcan.net.pl/"
+ "{locationID}/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/"
+ "{locationID}/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/"
+ "{locationID}/LoginEndpoint.aspx";
private String certificatePageUrl = "https://cufs.vulcan.net.pl/{locationID}"
+ "/FS/LS?wa=wsignin1.0&wtrealm=https://uonetplus.vulcan.net.pl/{locationID}"
+ "/LoginEndpoint.aspx&wctx=https://uonetplus.vulcan.net.pl/{locationID}"
+ "/LoginEndpoint.aspx";
private String loginEndpointPageUrl =
"https://uonetplus.vulcan.net.pl/{locationID}/LoginEndpoint.aspx";
@ -60,9 +59,7 @@ public class Login extends Vulcan {
private String[] getCertificateData(String county) throws IOException {
certificatePageUrl = certificatePageUrl.replace("{locationID}", county);
Document certificatePage = Jsoup.connect(certificatePageUrl)
.cookies(getCookies())
.get();
Document certificatePage = getPageByUrl(certificatePageUrl);
return new String[]{
certificatePage.select("input[name=wa]").attr("value"),

View File

@ -7,20 +7,24 @@ 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 AchievementsList {
private Notes notes = null;
private StudentAndParent snp = null;
private List<String> achievementsList = new ArrayList<>();
public AchievementsList(Notes notes) {
this.notes = notes;
private String notesPageUrl = "UwagiOsiagniecia.mvc/Wszystkie";
public AchievementsList(StudentAndParent snp) {
this.snp = snp;
}
public List<String> getAllAchievements() throws LoginErrorException, IOException {
Element pageFragment = notes.getNotesPageDocument().select(".mainContainer > div").get(1);
Element pageFragment = snp.getSnPPageDocument(notesPageUrl)
.select(".mainContainer > div").get(1);
Elements items = pageFragment.select("article");
for (Element item : items) {

View File

@ -1,33 +0,0 @@
package io.github.wulkanowy.api.notes;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class Notes extends Vulcan {
private StudentAndParent snp = null;
private String notesPageUrl = "https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/"
+ "UwagiOsiagniecia.mvc/Wszystkie";
public Notes(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
this.snp = snp;
}
public Document getNotesPageDocument() throws IOException, LoginErrorException {
notesPageUrl = notesPageUrl.replace("{locationID}", snp.getLocationID());
notesPageUrl = notesPageUrl.replace("{ID}", snp.getID());
return Jsoup.connect(notesPageUrl)
.cookies(getCookies())
.get();
}
}

View File

@ -12,18 +12,19 @@ import io.github.wulkanowy.api.login.LoginErrorException;
public class NotesList {
private Notes notes = null;
private StudentAndParent snp = null;
private List<Note> notesList = new ArrayList<>();
public NotesList(Notes notes, StudentAndParent snp) {
this.notes = notes;
private String notesPageUrl = "UwagiOsiagniecia.mvc/Wszystkie";
public NotesList(StudentAndParent snp) {
this.snp = snp;
}
public List<Note> getAllNotes() throws LoginErrorException, IOException {
Element pageFragment = notes.getNotesPageDocument().select(".mainContainer > div").get(0);
Element pageFragment = snp.getSnPPageDocument(notesPageUrl)
.select(".mainContainer > div").get(0);
Elements items = pageFragment.select("article");
Elements dates = pageFragment.select("h2");

View File

@ -1,32 +0,0 @@
package io.github.wulkanowy.api.school;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class School extends Vulcan {
private StudentAndParent snp = null;
private String schoolPageUrl = "https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/"
+ "Szkola.mvc/Nauczyciele";
public School(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
this.snp = snp;
}
public Document getSchoolPageDocument() throws IOException, LoginErrorException {
schoolPageUrl = schoolPageUrl.replace("{locationID}", snp.getLocationID());
schoolPageUrl = schoolPageUrl.replace("{ID}", snp.getID());
return Jsoup.connect(schoolPageUrl)
.cookies(getCookies())
.get();
}
}

View File

@ -10,16 +10,17 @@ import io.github.wulkanowy.api.login.LoginErrorException;
public class SchoolInfo extends Vulcan {
private School school = null;
private StudentAndParent snp = null;
public SchoolInfo(School school, StudentAndParent snp) {
this.school = school;
private String schoolPageUrl = "Szkola.mvc/Nauczyciele";
public SchoolInfo(StudentAndParent snp) {
this.snp = snp;
}
public SchoolData getSchoolData() throws IOException, LoginErrorException {
Element e = school.getSchoolPageDocument().select(".mainContainer > article").get(0);
Element e = snp.getSnPPageDocument(schoolPageUrl)
.select(".mainContainer > article").get(0);
return new SchoolData()
.setName(snp.getRowDataChildValue(e, 1))

View File

@ -8,19 +8,22 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class TeachersInfo extends Vulcan {
private School school = null;
private StudentAndParent snp = null;
public TeachersInfo(School school) {
this.school = school;
private String schoolPageUrl = "Szkola.mvc/Nauczyciele";
public TeachersInfo(StudentAndParent snp) {
this.snp = snp;
}
public TeachersData getTeachersData() throws IOException, LoginErrorException {
Document doc = school.getSchoolPageDocument();
Document doc = snp.getSnPPageDocument(schoolPageUrl);
Elements rows = doc.select(".mainContainer > table tbody tr");
String description = doc.select(".mainContainer > p").first().text();

View File

@ -3,23 +3,37 @@ 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() {

View File

@ -8,15 +8,18 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class Table extends Vulcan {
private Timetable timetable;
private StudentAndParent snp;
public Table(Timetable timetable) {
this.timetable = timetable;
private String timetablePageurl = "Lekcja.mvc/PlanLekcji?data=";
public Table(StudentAndParent snp) {
this.snp = snp;
}
public Week getWeekTable() throws IOException, LoginErrorException {
@ -24,7 +27,7 @@ public class Table extends Vulcan {
}
public Week getWeekTable(String tick) throws IOException, LoginErrorException {
Element table = timetable.getTablePageDocument(tick)
Element table = snp.getSnPPageDocument(timetablePageurl + tick)
.select(".mainContainer .presentData").first();
Elements tableHeaderCells = table.select("thead th");
@ -84,7 +87,7 @@ public class Table extends Vulcan {
.setDays(days);
}
public Lesson getLessonFromElement(Element e) {
private Lesson getLessonFromElement(Element e) {
Lesson lesson = new Lesson();
Elements spans = e.select("span");
@ -99,7 +102,7 @@ public class Table extends Vulcan {
return lesson;
}
public Lesson getLessonGroupDivisionInfo(Lesson lesson, Elements e) {
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);
@ -114,7 +117,7 @@ public class Table extends Vulcan {
return lesson;
}
public Lesson getLessonTypeInfo(Lesson lesson, Elements e) {
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)) {
@ -131,7 +134,7 @@ public class Table extends Vulcan {
return lesson;
}
public Lesson getLessonDescriptionInfo(Lesson lesson, Elements e) {
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))) {

View File

@ -1,33 +0,0 @@
package io.github.wulkanowy.api.timetable;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class Timetable extends Vulcan {
private StudentAndParent snp;
private String timetablePageurl =
"https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/Lekcja.mvc/PlanLekcji?data=";
public Timetable(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
this.snp = snp;
}
public Document getTablePageDocument(String tick) throws IOException, LoginErrorException {
timetablePageurl = timetablePageurl.replace("{locationID}", snp.getLocationID());
timetablePageurl = timetablePageurl.replace("{ID}", snp.getID());
return Jsoup.connect(timetablePageurl + tick)
.cookies(getCookies())
.get();
}
}

View File

@ -2,11 +2,11 @@ package io.github.wulkanowy.api.user;
public class AddressData {
private String address;
private String address = "";
private String registeredAddress;
private String registeredAddress = "";
private String correspondenceAddress;
private String correspondenceAddress = "";
public String getAddress() {
return address;

View File

@ -10,32 +10,45 @@ import io.github.wulkanowy.api.login.LoginErrorException;
public class BasicInformation {
private StudentAndParent snp = null;
private static Document studentDataPageDocument;
private Document studentDataPageDocument;
private StudentAndParent snp;
public BasicInformation(User user, StudentAndParent snp)
throws IOException, LoginErrorException {
private String studentDataPageUrl = "Uczen.mvc/DanePodstawowe";
public BasicInformation(StudentAndParent snp) {
this.snp = snp;
studentDataPageDocument = user.getPage();
}
public PersonalData getPersonalData() {
Element e = studentDataPageDocument.select(".mainContainer > article").get(0);
public Document getStudentDataPageDocument() throws IOException, LoginErrorException {
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()
.setNames(snp.getRowDataChildValue(e, 1))
.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(snp.getRowDataChildValue(e, 5))
.setPolishCitizenship("Tak".equals(snp.getRowDataChildValue(e, 5)))
.setFamilyName(snp.getRowDataChildValue(e, 6))
.setParentsNames(snp.getRowDataChildValue(e, 7));
}
public AddressData getAddresData() {
Element e = studentDataPageDocument.select(".mainContainer > article").get(1);
public AddressData getAddressData() throws IOException, LoginErrorException {
Element e = getStudentDataPageDocument().select(".mainContainer > article").get(1);
return new AddressData()
.setAddress(snp.getRowDataChildValue(e, 1))
@ -44,8 +57,8 @@ public class BasicInformation {
}
public ContactDetails getContactDetails() {
Element e = studentDataPageDocument.select(".mainContainer > article").get(2);
public ContactDetails getContactDetails() throws IOException, LoginErrorException {
Element e = getStudentDataPageDocument().select(".mainContainer > article").get(2);
return new ContactDetails()
.setPhoneNumber(snp.getRowDataChildValue(e, 1))

View File

@ -2,11 +2,11 @@ package io.github.wulkanowy.api.user;
public class ContactDetails {
private String phoneNumber;
private String phoneNumber = "";
private String cellPhoneNumber;
private String cellPhoneNumber = "";
private String email;
private String email = "";
public String getPhoneNumber() {
return phoneNumber;

View File

@ -0,0 +1,42 @@
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;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class FamilyInformation extends Vulcan {
private StudentAndParent snp;
private String studentDataPageUrl = "Uczen.mvc/DanePodstawowe";
public FamilyInformation(StudentAndParent snp) throws IOException, LoginErrorException {
this.snp = snp;
}
public List<FamilyMember> getFamilyMembers() throws IOException, LoginErrorException {
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;
}
}

View File

@ -0,0 +1,59 @@
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;
}
}

View File

@ -2,44 +2,60 @@ package io.github.wulkanowy.api.user;
public class PersonalData {
private String names;
private String name = "";
private String dateAndBirthPlace;
private String firstName = "";
private String pesel;
private String surname = "";
private String gender;
private String firstAndLastName = "";
private String isPolishCitizenship;
private String dateAndBirthPlace = "";
private String familyName;
private String pesel = "";
private String parentsNames;
private String gender = "";
public String getNames() {
return names;
private boolean isPolishCitizenship;
private String familyName = "";
private String parentsNames = "";
public String getName() {
return name;
}
public PersonalData setNames(String names) {
this.names = names;
public PersonalData setName(String name) {
this.name = name;
return this;
}
public String getFirstName() {
String[] name = names.split(" ");
return firstName;
}
return name[0];
public PersonalData setFirstName(String firstName) {
this.firstName = firstName;
return this;
}
public String getSurname() {
String[] name = names.split(" ");
return surname;
}
return name[name.length - 1];
public PersonalData setSurname(String surname) {
this.surname = surname;
return this;
}
public String getFirstAndLastName() {
return getFirstName() + " " + getSurname();
return firstAndLastName;
}
public PersonalData setFirstAndLastName(String firstAndLastName) {
this.firstAndLastName = firstAndLastName;
return this;
}
public String getDateAndBirthPlace() {
@ -48,7 +64,6 @@ public class PersonalData {
public PersonalData setDateAndBirthPlace(String dateAndBirthPlace) {
this.dateAndBirthPlace = dateAndBirthPlace;
return this;
}
@ -58,7 +73,6 @@ public class PersonalData {
public PersonalData setPesel(String pesel) {
this.pesel = pesel;
return this;
}
@ -68,17 +82,15 @@ public class PersonalData {
public PersonalData setGender(String gender) {
this.gender = gender;
return this;
}
public boolean isPolishCitizenship() {
return "Tak".equals(isPolishCitizenship);
return isPolishCitizenship;
}
public PersonalData setPolishCitizenship(String polishCitizenship) {
public PersonalData setPolishCitizenship(boolean polishCitizenship) {
isPolishCitizenship = polishCitizenship;
return this;
}
@ -88,7 +100,6 @@ public class PersonalData {
public PersonalData setFamilyName(String familyName) {
this.familyName = familyName;
return this;
}
@ -98,7 +109,6 @@ public class PersonalData {
public PersonalData setParentsNames(String parentsNames) {
this.parentsNames = parentsNames;
return this;
}
}

View File

@ -1,33 +0,0 @@
package io.github.wulkanowy.api.user;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import io.github.wulkanowy.api.Cookies;
import io.github.wulkanowy.api.StudentAndParent;
import io.github.wulkanowy.api.Vulcan;
import io.github.wulkanowy.api.login.LoginErrorException;
public class User extends Vulcan {
private StudentAndParent snp = null;
private String studentDataPageUrl =
"https://uonetplus-opiekun.vulcan.net.pl/{locationID}/{ID}/Uczen.mvc/DanePodstawowe";
public User(Cookies cookies, StudentAndParent snp) {
this.cookies = cookies;
this.snp = snp;
}
public Document getPage() throws IOException, LoginErrorException {
studentDataPageUrl = studentDataPageUrl.replace("{locationID}", snp.getLocationID());
studentDataPageUrl = studentDataPageUrl.replace("{ID}", snp.getID());
return Jsoup.connect(studentDataPageUrl)
.cookies(getCookies())
.get();
}
}