use of me.vertretungsplan.objects.SubstitutionScheduleDay in project substitution-schedule-parser by vertretungsplanme.
the class SubstitutionScheduleDiff method filterDaysClass.
private void filterDaysClass(String theClass, Set<String> excludedSubjects, List<SubstitutionScheduleDay> days) {
for (int i = 0; i < days.size(); i++) {
SubstitutionScheduleDay day = days.get(i);
SubstitutionScheduleDay filteredDay = day.clone();
filteredDay.setSubstitutions(day.getSubstitutionsByClassAndExcludedSubject(theClass, excludedSubjects));
days.set(i, filteredDay);
}
}
use of me.vertretungsplan.objects.SubstitutionScheduleDay in project substitution-schedule-parser by vertretungsplanme.
the class NotCompatibleParser method getSubstitutionSchedule.
@Override
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
SubstitutionSchedule v = SubstitutionSchedule.fromData(scheduleData);
v.setLastChange(new LocalDateTime(2017, 10, 18, 12, 4));
SubstitutionScheduleDay today = new SubstitutionScheduleDay();
today.setDate(new LocalDate(2018, 1, 1));
Substitution subst = new Substitution();
subst.setLesson("0");
subst.setClasses(new HashSet<>(getAllClasses()));
subst.setType("siehe Nachrichten");
subst.setDesc("Der Vertretungsplan kann von dieser Schule nicht mehr abgerufen werden. Genauere Informationen" + " findest du unter \"Nachrichten\".");
subst.setColor("#F44336");
today.addSubstitution(subst);
today.addMessage("Aus technischen Gründen kann der Vertretungsplan dieser Schule mit dieser App nicht mehr " + "abgerufen werden. " + (scheduleData.getApi().equals("dsbmobile") ? "Als Alternative kannst du vorerst die offizielle " + "App \"DSBmobile\" nutzen. " : "") + "Falls Sie eine Lehrkraft oder Schulleiter/-in an der Schule sind, melden Sie sich " + "bitte unter info@vertretungsplan.me bei uns, um herauszufinden, wie der Plan wieder in die App " + "aufgenommen werden kann. Falls Sie die Pro-Version der App gekauft haben, können wir " + "Ihnen das Geld zurückerstatten, wenn Sie sich per E-Mail an info@vertretungsplan.me bei uns melden.");
v.addDay(today);
v.setClasses(getAllClasses());
v.setTeachers(new ArrayList<String>());
return v;
}
use of me.vertretungsplan.objects.SubstitutionScheduleDay in project substitution-schedule-parser by vertretungsplanme.
the class SVPlanParser method parseSvPlanDay.
private void parseSvPlanDay(SubstitutionSchedule v, Element svp, Document doc) throws IOException, JSONException {
SubstitutionScheduleDay day = new SubstitutionScheduleDay();
if ((svp.select(".svp-plandatum-heute, .svp-plandatum-morgen, .Titel").size() > 0 || doc.title().startsWith("Vertretungsplan für "))) {
setDate(svp, doc, day);
final Elements tables = svp.select(".svp-tabelle, table:has(.Klasse)");
if (tables.size() > 0) {
Iterator<Element> iter = tables.iterator();
while (iter.hasNext()) {
Element table = iter.next();
if (!table.hasClass("svp-tabelle") && table.select("> tbody > tr > td.Klasse").size() == 0) {
iter.remove();
}
}
Elements rows = tables.select("tr");
String lastLesson = "";
String lastClass = "";
for (Element row : rows) {
if ((doc.select(".svp-header").size() > 0 && row.hasClass("svp-header")) || row.select("th").size() > 0 || row.text().trim().equals("")) {
continue;
}
Substitution substitution = new Substitution();
for (Element column : row.select("td")) {
String type = column.className();
if (!hasData(column.text())) {
if ((type.startsWith("svp-stunde") || type.startsWith("Stunde")) && hasData(lastLesson)) {
substitution.setLesson(lastLesson);
} else if ((type.startsWith("svp-klasse") || type.startsWith("Klasse")) && hasData(lastClass) && data.optBoolean(PARAM_REPEAT_CLASS, true)) {
substitution.getClasses().addAll(getClasses(lastClass));
}
continue;
}
if (type.startsWith("svp-stunde") || type.startsWith("Stunde")) {
substitution.setLesson(column.text());
lastLesson = column.text();
} else if (type.startsWith("svp-klasse") || type.startsWith("Klasse")) {
substitution.getClasses().addAll(getClasses(column.text()));
lastClass = column.text();
} else if (type.startsWith("svp-esfehlt") || type.startsWith("Lehrer")) {
if (!data.optBoolean(PARAM_EXCLUDE_TEACHERS)) {
substitution.setPreviousTeacher(column.text());
}
} else if (type.startsWith("svp-esvertritt") || type.startsWith("Vertretung")) {
if (!data.optBoolean(PARAM_EXCLUDE_TEACHERS)) {
substitution.setTeacher(column.text().replaceAll(" \\+$", ""));
}
} else if (type.startsWith("svp-fach") || type.startsWith("Fach")) {
substitution.setSubject(column.text());
} else if (type.startsWith("svp-bemerkung") || type.startsWith("Anmerkung")) {
substitution.setDesc(column.text());
String recognizedType = recognizeType(column.text());
substitution.setType(recognizedType);
substitution.setColor(colorProvider.getColor(recognizedType));
} else if (type.startsWith("svp-raum") || type.startsWith("Raum")) {
substitution.setRoom(column.text());
}
}
if (substitution.getType() == null) {
substitution.setType("Vertretung");
substitution.setColor(colorProvider.getColor("Vertretung"));
}
day.addSubstitution(substitution);
}
}
if (svp.select(".LehrerVerplant").size() > 0) {
day.addMessage("<b>Verplante Lehrer:</b> " + svp.select(".LehrerVerplant").text());
}
if (svp.select(".Abwesenheiten").size() > 0) {
day.addMessage("<b>Abwesenheiten:</b> " + svp.select(".Abwesenheiten").text());
}
if (svp.select("h2:contains(Mitteilungen)").size() > 0) {
Element h2 = svp.select("h2:contains(Mitteilungen)").first();
Element sibling = h2.nextElementSibling();
while (sibling != null && sibling.tagName().equals("p")) {
for (String nachricht : TextNode.createFromEncoded(sibling.html(), null).getWholeText().split("<br />\\s*<br />")) {
if (hasData(nachricht))
day.addMessage(nachricht);
}
sibling = sibling.nextElementSibling();
}
} else if (svp.select(".Mitteilungen").size() > 0) {
for (Element p : svp.select(".Mitteilungen")) {
for (String nachricht : TextNode.createFromEncoded(p.html(), null).getWholeText().split("<br />\\s*<br />")) {
if (hasData(nachricht))
day.addMessage(nachricht);
}
}
}
v.addDay(day);
} else {
throw new IOException("keine SVPlan-Tabelle gefunden");
}
}
use of me.vertretungsplan.objects.SubstitutionScheduleDay in project substitution-schedule-parser by vertretungsplanme.
the class TurboVertretungParser method parseTurboVertretungDay.
private void parseTurboVertretungDay(SubstitutionSchedule v, Document doc) {
SubstitutionScheduleDay day = new SubstitutionScheduleDay();
String date = doc.select(".Titel").text().replaceFirst("Vertretungsplan( für)? ", "");
day.setDate(DateTimeFormat.forPattern("EEEE, d. MMMM yyyy").withLocale(Locale.GERMAN).parseLocalDate(date));
String lastChange = doc.select(".Stand").text();
day.setLastChange(ParserUtils.parseDateTime(lastChange));
if (doc.text().contains("Kein Vertretungsplan")) {
v.addDay(day);
return;
}
if (doc.select(".LehrerFrueher").size() > 0) {
day.addMessage(doc.select(".LehrerFrueherLabel").text() + "\n" + doc.select(".LehrerFrueher").text());
}
if (doc.select(".LehrerVerplant").size() > 0) {
day.addMessage(doc.select(".LehrerVerplantLabel").text() + "\n" + doc.select(".LehrerVerplant").text());
}
if (doc.select(".Abwesenheiten-Klassen").size() > 0) {
day.addMessage(doc.select(".Abwesenheiten-KlassenLabel").text() + "\n" + doc.select(".Abwesenheiten-Klassen").text());
}
if (doc.select(".Abwesenheiten").size() > 0) {
day.addMessage(doc.select(".AbwesenheitenLabel").text() + "\n" + doc.select(".Abwesenheiten").text());
}
Element table = doc.select("table").first();
for (Element row : table.select("tr:has(td)")) {
if (row.select(".Klasseleer").size() > 0)
continue;
Substitution substitution = new Substitution();
substitution.setLesson(row.select(query("Stunde")).text());
substitution.setPreviousTeacher(row.select(query("Lehrer")).text());
substitution.setTeacher(row.select(query("Vertretung")).text());
substitution.setClasses(new HashSet<>(Arrays.asList(row.select(query("Klasse")).text().split(" "))));
substitution.setSubject(row.select(query("Fach")).text());
substitution.setDesc(row.select(query("Anmerkung")).text());
substitution.setRoom(row.select(query("Raum")).text());
String type = recognizeType(row.select(query("Anmerkung")).text());
if (type == null)
type = "Vertretung";
substitution.setType(type);
substitution.setColor(colorProvider.getColor(type));
day.addSubstitution(substitution);
}
v.addDay(day);
}
use of me.vertretungsplan.objects.SubstitutionScheduleDay in project substitution-schedule-parser by vertretungsplanme.
the class UntisInfoParser method parseSubstitutionDays.
void parseSubstitutionDays(SubstitutionSchedule v, String lastChange, Document doc, String klasse, List<String> allClasses) throws JSONException, CredentialInvalidException, IOException {
Elements days = doc.select("#vertretung > p > b, #vertretung > b, p:has(a[href^=#]) > b");
if (days.size() > 0) {
for (Element dayElem : days) {
SubstitutionScheduleDay day = new SubstitutionScheduleDay();
day.setLastChangeString(lastChange);
day.setLastChange(ParserUtils.parseDateTime(lastChange));
String date = dayElem.text();
day.setDateString(date);
day.setDate(ParserUtils.parseDate(date));
Element next;
if (dayElem.parent().tagName().equals("p")) {
next = dayElem.parent().nextElementSibling().nextElementSibling();
} else {
next = dayElem.parent().select("p").first().nextElementSibling();
}
parseDay(day, next, v, klasse, allClasses);
}
} else if (doc.select("tr:has(td[align=center]):gt(0)").size() > 0) {
parseSubstitutionTable(v, null, doc);
v.setLastChangeString(lastChange);
v.setLastChange(ParserUtils.parseDateTime(lastChange));
}
}
Aggregations