Skip to content

Commit

Permalink
fix: revert everything
Browse files Browse the repository at this point in the history
  • Loading branch information
to-kn committed Aug 19, 2024
1 parent 1f8a987 commit ff643e3
Show file tree
Hide file tree
Showing 19 changed files with 42 additions and 40 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,3 @@ jobs:
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

trigger_jitpack:
runs-on: ubuntu-latest
steps:
- name: Trigger Jitpack Build
run: curl "https://jitpack.io/com/github/vertretungsplanme/substitution-schedule-parser/${GITHUB_SHA:0:10}/build.log"
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ allprojects {
mavenCentral()
}
}

buildscript {
repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion parser/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ model {

test {
maxHeapSize = "1g"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Parser information about cancellation of classes caused by snow or other extreme weather conditions provided as an
* RSS feed by the Ministry of Education of Schleswig-Holstein, Germany.
* Same as <a href="http://www.schleswig-holstein.de/DE/Landesregierung/III/Service/winterhotline/Winterhotline.html">...</a>
* Same as http://www.schleswig-holstein.de/DE/Landesregierung/III/Service/winterhotline/Winterhotline.html
* Can be used for all public and vocational schools in Schleswig-Holstein.
*/
public class WinterShParser extends BaseAdditionalInfoParser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void setClasses(Set<String> classes) {

/**
* Get the lesson which this substitution is for.
* <p>
*
* Keep it short, the recommended format is e.g. "1" for single lessons and "5-6" for multiple lessons. But some
* schools use different ways to name their lessons.
*
Expand All @@ -117,7 +117,7 @@ public String getLesson() {

/**
* Set the lesson which this substitution is for.
* <p>
*
* Keep it short, the recommended format is e.g. "1" for single lessons and "5-6" for multiple lessons. But some
* schools use different ways to name their lessons. Required.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void setApi(String api) {
* {@link me.vertretungsplan.additionalinfo.BaseAdditionalInfoParser#getInstance(String)} to create a suitable
* parser instance.
*
* @return the list of additional info types
* @return the set of additional info types
*/
public List<String> getAdditionalInfos() {
return additionalInfos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface Credential {
* This can be used to differentiate between two credentials or to allow a user to authenticate to an application
* which uses this parser. <b>It should not be used by {@link me.vertretungsplan.parser.SubstitutionScheduleParser}
* implementations, especially not if they depend on a specific hashing algorithm.</b>
* <p>
*
* For two Credential objects a and b, the following relation should apply:
* a.getHash().equals(b.getHash()) if and only if a.getLoginData().equals(b.getLoginData())
*
Expand Down
9 changes: 5 additions & 4 deletions parser/src/main/java/me/vertretungsplan/parser/CSVParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;

/**
Expand Down Expand Up @@ -126,7 +127,7 @@ public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONEx
schedule.setLastChange(modified);
}
InputStream stream = client.get(new URI(httpUrl).resolve(file.getHref()).toString());
parseCSV(IOUtils.toString(stream, StandardCharsets.UTF_8), schedule);
parseCSV(IOUtils.toString(stream, "UTF-8"), schedule);
}
}
} catch (GeneralSecurityException | URISyntaxException e) {
Expand All @@ -153,7 +154,7 @@ public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONEx
schedule.setLastChange(modified);
}
InputStream stream = client.get(new URI(httpUrl).resolve(file.getHref()).toString());
schedule = parseCSVAdditionalInfos(IOUtils.toString(stream, StandardCharsets.UTF_8), schedule);
schedule = parseCSVAdditionalInfos(IOUtils.toString(stream, "UTF-8"), schedule);
}
}
} catch (GeneralSecurityException | URISyntaxException e) {
Expand Down Expand Up @@ -207,7 +208,7 @@ SubstitutionSchedule parseCSVAdditionalInfos(String response, SubstitutionSchedu
}
j++;
}
if (info.getText() != null && !info.getText().trim().isEmpty()) {
if (info.getText() != null && !info.getText().trim().equals("")) {
Boolean isDayMessage = false;
for (SubstitutionScheduleDay day : schedule.getDays()) {
if (day.getDate().equals(ParserUtils.parseDate(info.getTitle()))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand All @@ -27,7 +26,7 @@ public class ColumnTypeDetector {
public ColumnTypeDetector() throws IOException, JSONException {
columns = new HashMap<>();
InputStream is = getClass().getClassLoader().getResourceAsStream("column_headers.json");
String content = IOUtils.toString(is, StandardCharsets.UTF_8);
String content = IOUtils.toString(is, "UTF-8");
JSONObject json = new JSONObject(content);
for (Iterator it = json.keys(); it.hasNext(); ) {
String type = (String) it.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ private String handleLogin(Executor executor, CookieStore cookieStore, boolean n
Element iframe = doc.select("iframe").first();
if (iframe == null) throw new CredentialInvalidException();
String url = iframe.absUrl("src");
if (url != null && !url.isEmpty()) {
if (url != null && !url.equals("")) {
executor.execute(Request.Get(url)).discardContent();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static synchronized void init() {
}

private static synchronized void reinitIfNeeded() {
if (dateFormatters.isEmpty() || dateFormatters.get(0).getDefaultYear() != DateTime.now().getYear()) {
if (dateFormatters.size() == 0 || dateFormatters.get(0).getDefaultYear() != DateTime.now().getYear()) {
init();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void parseSubstitutionScheduleTable(Element table, JSONObject data,
for (Element headerRow : headerRows) {
final String text = headerRow.select("th").get(i).text().replace("\u00a0", " ").trim();
if (first) {
if (!text.isEmpty()) first = false;
if (!text.equals("")) first = false;
} else {
builder.append(" ");
}
Expand Down Expand Up @@ -414,7 +414,7 @@ private void parseSubstitutionScheduleTable(Element table, JSONObject data,
v.setSubject(course);
}

if (v.getLesson() == null || v.getLesson().isEmpty()) {
if (v.getLesson() == null || v.getLesson().equals("")) {
continue;
}

Expand Down Expand Up @@ -726,7 +726,7 @@ private void parseWithExtraLine(JSONObject data, SubstitutionScheduleDay day, Li
v.setTeacher(teacherName);
}

if (v.getLesson() != null && !v.getLesson().isEmpty()) {
if (v.getLesson() != null && !v.getLesson().equals("")) {
day.addSubstitution(v);
}

Expand Down Expand Up @@ -838,7 +838,7 @@ static void handleSubject(Substitution subst, Element cell, boolean previousSubj

private boolean isEmpty(String text) {
final String trim = text.replaceAll("\u00A0", "").trim();
return trim.isEmpty() || trim.equals("---") || trim.equals("+");
return trim.equals("") || trim.equals("---") || trim.equals("+");
}

/**
Expand Down Expand Up @@ -866,7 +866,7 @@ private void parseMessages(Element table, SubstitutionScheduleDay day) {
SubstitutionScheduleDay parseMonitorDay(Element doc, JSONObject data) throws
JSONException, CredentialInvalidException, IOException {
SubstitutionScheduleDay day = new SubstitutionScheduleDay();
String date = Objects.requireNonNull(doc.select(".mon_title").first()).text().replaceAll(" \\(Seite \\d+ / \\d+\\)", "");
String date = doc.select(".mon_title").first().text().replaceAll(" \\(Seite \\d+ / \\d+\\)", "");
day.setDateString(date);
day.setDate(ParserUtils.parseDate(date));

Expand Down Expand Up @@ -982,6 +982,11 @@ protected void parseSubstitutionTable(SubstitutionSchedule v, String lastChange,
/**
* Parses an Untis substitution table ({@link UntisSubstitutionParser}).
*
* @param v
* @param lastChange
* @param doc
* @throws JSONException
* @throws CredentialInvalidException
*/
protected void parseSubstitutionTable(SubstitutionSchedule v, String lastChange, Document doc, String className)
throws JSONException, CredentialInvalidException, IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private static List<Substitution> parseTimetableCell(Element cell, String lesson
cellFormat, ColorProvider colorProvider)
throws JSONException {
List<Substitution> substitutions = new ArrayList<>();
if (cell.text().trim().isEmpty()) {
if (cell.text().trim().equals("")) {
return substitutions;
}

Expand Down Expand Up @@ -383,7 +383,7 @@ private static List<Substitution> parseTimetableCell(Element cell, String lesson

try {
Element td = tr.select("td").get(col + course * cellFormat.getJSONArray(0).length());
if (!td.select("font[color=#FF0000]").isEmpty()) {
if (td.select("font[color=#FF0000]").size() > 0) {
isChange = true;
}

Expand Down Expand Up @@ -449,7 +449,7 @@ void parseSubstitutionDays(SubstitutionSchedule v, String lastChange, Document d
allClasses)
throws JSONException, CredentialInvalidException, IOException {
Elements days = doc.select("#vertretung > p > b, #vertretung > b, p:has(a[href^=#]) > b");
if (!days.isEmpty()) {
if (days.size() > 0) {
for (Element dayElem : days) {
SubstitutionScheduleDay day = new SubstitutionScheduleDay();

Expand All @@ -468,7 +468,7 @@ void parseSubstitutionDays(SubstitutionSchedule v, String lastChange, Document d
}
parseDay(day, next, v, klasse, allClasses);
}
} else if (!doc.select("tr:has(td[align=center]):gt(0)").isEmpty()) {
} 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
* <dt><code>jwt_key</code> (String, required)</dt>
* <dd>The key used for signing the JWT</dd>
* </dl>
* <p>
*
* You have to use a {@link me.vertretungsplan.objects.authentication.PasswordAuthenticationData} because all
* schedules on VPO are protected by a login.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private static String changedTeacher(String teacher, String previousTeacher) {
static boolean hasData(String string) {
if (string != null) {
String s = string.replaceAll("\\s", "");
return !(s.isEmpty() || s.equals("---"));
return !(s.equals("") || s.equals("---"));
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package me.vertretungsplan.parser;

import java.io.*;
import java.nio.charset.StandardCharsets;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -23,7 +22,11 @@ public class BaseDemoTest {
*/
private static String convertStreamToString(InputStream is) throws IOException {
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
try {
reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
} catch (UnsupportedEncodingException e1) {
reader = new BufferedReader(new InputStreamReader(is));
}
StringBuilder sb = new StringBuilder();

String line;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import java.io.IOException;
import java.util.List;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class DaVinciDemoTest extends BaseDemoTest {
private static final String EXAMPLE_URL = "http://example.com";
Expand Down Expand Up @@ -77,7 +78,7 @@ public void singleTest5() throws IOException, JSONException {

private void checkSubstitutions(SubstitutionScheduleDay day) {
for (Substitution subst : day.getSubstitutions()) {
assertFalse(subst.getClasses().isEmpty());
assertTrue(subst.getClasses().size() > 0);
assertNotEmpty(subst.getLesson());
assertNotEmpty(subst.getPreviousSubject());
assertNullOrNotEmpty(subst.getSubject());
Expand All @@ -100,7 +101,7 @@ public void testDayIndex() throws IOException {
List<String> urls = DaVinciParser.getDayUrls(EXAMPLE_URL, Jsoup.parse(htmlDayIndex));
assertEquals(7, urls.size());
for (int i = 0; i < urls.size(); i++) {
assertEquals(EXAMPLE_URL + "/V_DC_00" + (i + 1) + ".html", urls.get(i));
assertEquals(EXAMPLE_URL + "/V_DC_00" + String.valueOf(i + 1) + ".html", urls.get(i));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void demoTest3() throws IOException, JSONException {
assertEquals(0, day.getMessages().size());

for (Substitution subst : day.getSubstitutions()) {
if (!subst.getSubject().equals("Profi")) assertTrue(!subst.getClasses().isEmpty());
if (!subst.getSubject().equals("Profi")) assertTrue(subst.getClasses().size() >= 1);
assertNotEmpty(subst.getLesson());
assertNullOrNotEmpty(subst.getPreviousSubject());
assertNotEmpty(subst.getSubject());
Expand All @@ -157,7 +157,7 @@ public void demoTest4() throws IOException, JSONException {

for (Substitution subst : schedule2.getDays().get(0).getSubstitutions()) {
if (subst.getSubject().equals("Netzw")) {
assertTrue(subst.getClasses().isEmpty());
assertTrue(subst.getClasses().size() == 0);
} else {
assertTrue(subst.getClasses().size() == 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private int complexity(String... args) {
private boolean bothOrNoneEmpty(@Strings(values = {"", "Fach"}) String subject1,
@Strings(values = {"", "Fach", "Fach2"})
String subject2) {
return subject1.isEmpty() && subject2.isEmpty() || !subject1.isEmpty() && !subject2.isEmpty();
return subject1.equals("") && subject2.equals("") || !subject1.equals("") && !subject2.equals("");
}

@Retention(RetentionPolicy.RUNTIME)
Expand Down

0 comments on commit ff643e3

Please sign in to comment.