Add support for parameters to start and update gradle to compile full jar
This commit is contained in:
15
build.gradle
15
build.gradle
@@ -26,4 +26,19 @@ dependencies {
|
||||
compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
|
||||
compile 'com.google.apis:google-api-services-calendar:v3-rev305-1.23.0'
|
||||
compile 'com.google.guava:guava:29.0-jre'
|
||||
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1'
|
||||
compile group: 'net.sourceforge.argparse4j', name: 'argparse4j', version: '0.8.1'
|
||||
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.3'
|
||||
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.3'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'de.jeyp91.App'
|
||||
)
|
||||
}
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package de.jeyp91;
|
||||
|
||||
|
||||
import de.jeyp91.tippliga.*;
|
||||
import net.sourceforge.argparse4j.ArgumentParsers;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParser;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
@@ -9,49 +11,76 @@ import de.jeyp91.tippliga.*;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static String mode;
|
||||
private static int season;
|
||||
private static int league;
|
||||
private static String configFile;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
//getMatchesFromDatabase();
|
||||
//updateMatchesFromOpenLigaDB();
|
||||
//con.close();
|
||||
|
||||
System.out.println("done");
|
||||
initOptions(args);
|
||||
String sql = "";
|
||||
switch(mode) {
|
||||
case "MatchdaysUpdater":
|
||||
TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(season, league, configFile);
|
||||
sql = matchdaysUpdater.getUpdateSql();
|
||||
break;
|
||||
case "MatchesCreatorFootball":
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, league, configFile);
|
||||
sql = creator.getSQLInsertString();
|
||||
break;
|
||||
case "MatchesUpdaterFootball":
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(season, league, configFile);
|
||||
sql = updater.getUpdateSQL();
|
||||
break;
|
||||
case "TeamsUpdater":
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(season, league, configFile);
|
||||
sql = teamsUpdater.getInsertSQL();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!StatusHolder.getError()) {
|
||||
TippligaSQLConnector con = new TippligaSQLConnector();
|
||||
con.executeQuery(sql);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static void getMatchesFromDatabase() throws SQLException {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE season = 2019 AND league = 1";
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet rset = stmt.executeQuery(queryString);
|
||||
ArrayList<Match> matches = new ArrayList<Match>();
|
||||
while (rset.next()) {
|
||||
matches.add(new Match(rset));
|
||||
}
|
||||
}
|
||||
*/
|
||||
private static void initOptions(String[] args) {
|
||||
ArgumentParser parser = ArgumentParsers.newFor("tlw").build()
|
||||
.defaultHelp(true)
|
||||
.description("");
|
||||
|
||||
/*
|
||||
public static void updateMatchesFromOpenLigaDB() throws Exception {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE season = 2018 AND league = 48";
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet rset = stmt.executeQuery(queryString);
|
||||
ArrayList<Match> matchesTLW = new ArrayList<Match>();
|
||||
while (rset.next()) {
|
||||
matchesTLW.add(new Match(rset));
|
||||
}
|
||||
parser.addArgument("-m", "--mode")
|
||||
.dest("mode")
|
||||
.choices("MatchdaysUpdater", "MatchesCreatorFootball", "MatchesUpdaterFootball", "TeamsUpdater")
|
||||
.help("")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
// Download data from OpenLigaDB
|
||||
JSONArray matchDBJson = new JSONArray();
|
||||
OpenLigaDB openLigaDB = new OpenLigaDB();
|
||||
for (int i = 1; i <= 6; i++) {
|
||||
// matchDBJson.put(OpenLigaDB.downloadMatchday(2020, "bl1", i));
|
||||
// matchDBJson.put(OpenLigaDB.downloadMatchday(2020, "bl2", i));
|
||||
// matchDBJson.put(OpenLigaDB.downloadMatchday(2020, "bl3", i));
|
||||
matchDBJson.add(openLigaDB.getMatchesOfMatchdayAsJSONArray(2018, "dfb", i));
|
||||
}
|
||||
parser.addArgument("-s", "--season")
|
||||
.dest("season")
|
||||
.required(true)
|
||||
.type(Integer.class);
|
||||
|
||||
for (Match match : matchesTLW) {
|
||||
match.updateDataFromOpenLigaDb(matchDBJson);
|
||||
parser.addArgument("-l", "--league")
|
||||
.dest("league")
|
||||
.required(true)
|
||||
.type(Integer.class);
|
||||
|
||||
parser.addArgument("-c", "--configFile")
|
||||
.dest("configFile")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
Namespace res = null;
|
||||
try {
|
||||
res = parser.parseArgs(args);
|
||||
} catch (ArgumentParserException e) {
|
||||
parser.printHelp();
|
||||
System.exit(1);
|
||||
}
|
||||
mode = res.get("mode");
|
||||
season = res.get("season");
|
||||
league = res.get("league");
|
||||
configFile = res.get("configFile");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class MatchUtils {
|
||||
|
||||
/*
|
||||
|
||||
public void updateDataFromOpenLigaDb(JSONArray openLigaDbData) throws Exception {
|
||||
loopOverAllMatchdays:
|
||||
for(int i = 0; i < openLigaDbData.size(); i++) {
|
||||
for(int j = 0; j < ((JSONArray)(openLigaDbData.get(i))).size(); j++) {
|
||||
Match tempMatch = new Match(this.season, this.league, this.matchday, this.matchNo, (JSONObject)(((JSONArray)openLigaDbData.get(i)).get(j)));
|
||||
if(isSameMatch(tempMatch)) {
|
||||
break loopOverAllMatchdays;
|
||||
}
|
||||
updateDateTime(tempMatch);
|
||||
updateResult(tempMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateDateTime(Match compareMatch) {
|
||||
if(!this.getSeason().equals(compareMatch.getSeason())) {
|
||||
return false;
|
||||
}
|
||||
if(!this.getLeague().equals(compareMatch.getLeague())) {
|
||||
return false;
|
||||
}
|
||||
if(!this.getMatchday().equals(compareMatch.getMatchday())) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdHome() == null || compareMatch.getTeamIdHome() == null
|
||||
|| (this.getTeamIdHome() != compareMatch.getTeamIdHome())) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdGuest() == null || compareMatch.getTeamIdGuest() == null
|
||||
|| (this.getTeamIdGuest() != compareMatch.getTeamIdGuest())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
||||
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
||||
if(!tempDateTime.equals(thisDateTime)) {
|
||||
// System.out.println(String.valueOf(this.matchNo) + ":");
|
||||
// System.out.println("Old date: " + thisDateTime + "; New date: " + tempDateTime);
|
||||
// System.out.println();
|
||||
|
||||
// String updateQuery = "UPDATE phpbb_footb_matches SET match_datetime = '" + tempDateTime + "' WHERE season = " + this.season + " AND league = " + this.league + " AND match_no = " + this.matchNo + " AND team_id_home = " + this.teamIdHome + " AND team_id_guest = " + this.teamIdGuest + " AND match_datetime = '" + this.matchDatetime + "';";
|
||||
// System.out.println(updateQuery);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateResult(Match compareMatch) {
|
||||
if(!this.getSeason().equals(compareMatch.getSeason())) {
|
||||
return false;
|
||||
}
|
||||
if(!this.getLeague().equals(compareMatch.getLeague())) {
|
||||
return false;
|
||||
}
|
||||
if(!this.getMatchday().equals(compareMatch.getMatchday())) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdHome() == null || compareMatch.getTeamIdHome() == null
|
||||
|| (this.getTeamIdHome() != compareMatch.getTeamIdHome())) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdGuest() == null || compareMatch.getTeamIdGuest() == null
|
||||
|| (this.getTeamIdGuest() != compareMatch.getTeamIdGuest())) {
|
||||
return false;
|
||||
}
|
||||
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
||||
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
||||
if(!tempDateTime.equals(thisDateTime)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.goalsHome != compareMatch.goalsHome ||
|
||||
this.goalsGuest != compareMatch.goalsGuest &&
|
||||
this.goalsHome != null && this.goalsGuest != null && compareMatch.goalsHome != null && compareMatch.goalsGuest != null) {
|
||||
String oldResult = String.valueOf(this.goalsHome) + " : " + String.valueOf(this.goalsGuest);
|
||||
String newResult = String.valueOf(compareMatch.goalsHome) + " : " + String.valueOf(compareMatch.goalsGuest);
|
||||
|
||||
System.out.println(String.valueOf(this.matchNo) + ":");
|
||||
System.out.println(this.matchDatetime + " Old result: " + oldResult + "; New result: " + newResult);
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
11
src/main/java/de/jeyp91/StatusHolder.java
Normal file
11
src/main/java/de/jeyp91/StatusHolder.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package de.jeyp91;
|
||||
|
||||
public class StatusHolder {
|
||||
private static boolean error = false;
|
||||
public static void setError() {
|
||||
error = true;
|
||||
}
|
||||
public static boolean getError() {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.Resources;
|
||||
import org.apache.logging.log4j.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -14,6 +15,7 @@ import org.json.simple.parser.ParseException;
|
||||
public class TeamIDMatcher {
|
||||
|
||||
private static HashBiMap<Integer, Integer> ids = null;
|
||||
private static Logger logger = LogManager.getLogger(TeamIDMatcher.class);
|
||||
|
||||
private static void initBiMap() {
|
||||
ids = HashBiMap.create();
|
||||
@@ -44,8 +46,8 @@ public class TeamIDMatcher {
|
||||
if(ids.containsKey(id)) {
|
||||
return ids.get(id);
|
||||
} else {
|
||||
// System.out.println("ID: " + String.valueOf(id) + " not in ID Matcher.");
|
||||
System.out.println(String.valueOf(id));
|
||||
logger.error("Tippliga ID: " + String.valueOf(id) + " not in ID Matcher.");
|
||||
StatusHolder.setError();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -58,7 +60,8 @@ public class TeamIDMatcher {
|
||||
if(ids.inverse().containsKey(id)) {
|
||||
return ids.inverse().get(id);
|
||||
} else {
|
||||
System.out.println("ID: " + String.valueOf(id) + " not in ID Matcher.");
|
||||
logger.error("API Football ID: " + String.valueOf(id) + " not in ID Matcher.");
|
||||
StatusHolder.setError();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import de.jeyp91.tippliga.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TeamValidator {
|
||||
|
||||
private final int INCONSISTENT_TEAM_ID = 0;
|
||||
private final int INCONSISTENT_TEAM_NAME = 1;
|
||||
private final int INCONSISTENT_TEAM_NAME_SHORT = 2;
|
||||
private final int INCONSISTENT_TEAM_SYMBOL = 3;
|
||||
|
||||
private ArrayList<TLWTeam> teams;
|
||||
|
||||
public TeamValidator(ArrayList<TLWTeam> teams) {
|
||||
this.teams = teams;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
ArrayList<TLWTeam> tempTeams = teams;
|
||||
while(tempTeams.size() > 0) {
|
||||
TLWTeam referenceTeam = tempTeams.get(0);
|
||||
tempTeams.remove(0);
|
||||
|
||||
ArrayList<TLWTeam> finishedTeams = new ArrayList<TLWTeam>();
|
||||
for (TLWTeam team : tempTeams) {
|
||||
if(referenceTeam.getTeamSymbol().equals(team.getTeamSymbol()) && !referenceTeam.getTeamSymbol().equals("blank.gif")) {
|
||||
finishedTeams.add(team);
|
||||
compareTeams(referenceTeam, team);
|
||||
}
|
||||
}
|
||||
|
||||
for (TLWTeam team : finishedTeams) {
|
||||
tempTeams.remove(team);
|
||||
}
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
private int compareTeams(TLWTeam team1, TLWTeam team2) {
|
||||
if(team1.getTeamId() != team2.getTeamId()) {
|
||||
// System.out.println("Team ID wrong" + team1.getTeamId() + " " + team2.getTeamId());
|
||||
String update = "UPDATE phpbb_footb_teams SET team_id = " + String.valueOf(team1.getTeamId()) + " WHERE team_name = '" + team1.getTeamName() + "' AND team_name_short = '" + team1.getTeamNameShort() + "' AND team_symbol = '" + team1.getTeamSymbol() + "';";
|
||||
System.out.println(update);
|
||||
return INCONSISTENT_TEAM_ID;
|
||||
}
|
||||
if(!team1.getTeamName().equals(team2.getTeamName())) {
|
||||
// System.out.println("Team Name wrong: " + team1.getTeamName() + " " + team2.getTeamName());
|
||||
String update = "UPDATE phpbb_footb_teams SET team_name = '" + team1.getTeamName() + "' WHERE team_id = " + String.valueOf(team1.getTeamId()) + " AND team_name_short = '" + team1.getTeamNameShort() + "' AND team_symbol = '" + team1.getTeamSymbol() + "';";
|
||||
System.out.println(update);
|
||||
return INCONSISTENT_TEAM_NAME;
|
||||
}
|
||||
if(!team1.getTeamNameShort().equals(team2.getTeamNameShort())) {
|
||||
// System.out.println("Team Name Short wrong: " + team1.getTeamNameShort() + " " + team2.getTeamNameShort());
|
||||
String update = "UPDATE phpbb_footb_teams SET team_name_short = '" + team1.getTeamNameShort() + "' WHERE team_id = " + String.valueOf(team1.getTeamId()) + " AND team_name = '" + team1.getTeamName() + "' AND team_symbol = '" + team1.getTeamSymbol() + "';";
|
||||
System.out.println(update);
|
||||
return INCONSISTENT_TEAM_NAME_SHORT;
|
||||
}
|
||||
if(!team1.getTeamSymbol().equals(team2.getTeamSymbol())) {
|
||||
// System.out.println("Team Symbol wrong: " + team1.getTeamSymbol() + " " + team2.getTeamSymbol());
|
||||
String update = "UPDATE phpbb_footb_teams SET team_symbol = '" + team1.getTeamSymbol() + "' WHERE team_id = " + String.valueOf(team1.getTeamId()) + " AND team_name = '" + team1.getTeamName() + "' AND team_name_short = '" + team1.getTeamNameShort() + "';";
|
||||
System.out.println(update);
|
||||
return INCONSISTENT_TEAM_SYMBOL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class APIFootballConnector {
|
||||
|
||||
private final String API_FOOTBALL_URL = "https://v2.api-football.com/";
|
||||
private int season;
|
||||
|
||||
public APIFootballConnector(int season) {
|
||||
|
||||
2
src/main/java/de/jeyp91/gists/GistProvider.java
Normal file
2
src/main/java/de/jeyp91/gists/GistProvider.java
Normal file
@@ -0,0 +1,2 @@
|
||||
package de.jeyp91.gists;public class GistProvider {
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
public class TLWFootballMatchesUpdater {
|
||||
public TLWFootballMatchesUpdater() {
|
||||
|
||||
}
|
||||
|
||||
public String getUpdateSQL() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,20 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.jeyp91.BaseMatch;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.openligadb.OpenLigaDBMatch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TLWMatch extends BaseMatch{
|
||||
|
||||
private final Logger logger = LogManager.getLogger(TLWMatch.class);
|
||||
|
||||
public final Integer STATUS_NOTSTARTED = 0;
|
||||
public final Integer STATUS_STARTED = 1;
|
||||
public final Integer STATUS_PROVISIONAL_RESULT_AVAILABLE = 2;
|
||||
@@ -274,7 +279,8 @@ public class TLWMatch extends BaseMatch{
|
||||
private Integer getTeamIdHomeFromApiFootballMatch(APIFootballMatch match) {
|
||||
Integer id = TeamIDMatcher.getTippligaIdFromApiFootballId(match.getTeamIdHome());
|
||||
if(id == null) {
|
||||
System.out.println("Could not find id " + match.getTeamIdHome() + " for " + match.getTeamNameHome());
|
||||
logger.error("Could not find id " + match.getTeamIdHome() + " for " + match.getTeamNameHome());
|
||||
StatusHolder.setError();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@@ -282,7 +288,8 @@ public class TLWMatch extends BaseMatch{
|
||||
private Integer getTeamIdGuestFromApiFootballMatch(APIFootballMatch match) {
|
||||
Integer id = TeamIDMatcher.getTippligaIdFromApiFootballId(match.getTeamIdGuest());
|
||||
if(id == null) {
|
||||
System.out.println("Could not find id " + match.getTeamIdGuest() + " for " + match.getTeamNameGuest());
|
||||
logger.error("Could not find id " + match.getTeamIdGuest() + " for " + match.getTeamNameGuest());
|
||||
StatusHolder.setError();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class TLWMatchdaysCreator {
|
||||
|
||||
int numberOfMatches = this.matchesPerMatchday;
|
||||
if(numberOfMatches == 0){
|
||||
numberOfMatches = Integer.parseInt(matchdayConfigJson.get("matchesPerMatchday").toString());
|
||||
numberOfMatches = Integer.parseInt(matchdayConfigJson.get("numberOfMatches").toString());
|
||||
}
|
||||
|
||||
String deliveryDate1 = null;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -13,6 +16,8 @@ import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
|
||||
private final Logger logger = LogManager.getLogger(TLWMatchesCreatorTipperLeague.class);
|
||||
|
||||
int season;
|
||||
int league;
|
||||
|
||||
@@ -84,7 +89,8 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
}
|
||||
}
|
||||
if(teamId == 0) {
|
||||
System.out.println("ERROR! Did not find Tipper ID for " + name);
|
||||
logger.error("ERROR! Did not find Tipper ID for " + name);
|
||||
StatusHolder.setError();
|
||||
}
|
||||
return teamId;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -13,6 +15,8 @@ import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
|
||||
Logger logger = LogManager.getLogger(TLWMatchesCreatorTipperPokal.class);
|
||||
|
||||
int season;
|
||||
int league;
|
||||
|
||||
@@ -74,7 +78,7 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
}
|
||||
}
|
||||
if(teamId == 0) {
|
||||
System.out.println("Did not find Tipper ID for " + name);
|
||||
logger.error("Did not find Tipper ID for " + name);
|
||||
}
|
||||
return teamId;
|
||||
}
|
||||
|
||||
@@ -182,4 +182,8 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
}
|
||||
return matchingMatch;
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getTLWMatchesUpdated() {
|
||||
return this.tlwMatchesUpdated;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,20 @@ public class TLWTeamsUpdater {
|
||||
ArrayList<TLWMatch> matchesUpdated;
|
||||
ArrayList<TLWTeam> missingTeams;
|
||||
|
||||
public TLWTeamsUpdater(int season, int league, ArrayList<TLWMatch> matchesUpdated) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchesUpdated = matchesUpdated;
|
||||
missingTeams = new ArrayList<>();
|
||||
public TLWTeamsUpdater(int season, int league, String configFileName) throws Exception {
|
||||
|
||||
TippligaSQLConnector conn = new TippligaSQLConnector();
|
||||
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchesUpdated = new ArrayList<>();
|
||||
|
||||
TLWMatchesUpdaterFootball matchesUpdaterFootball = new TLWMatchesUpdaterFootball(season, league, configFileName);
|
||||
this.matchesUpdated.addAll(matchesUpdaterFootball.getTLWMatchesUpdated());
|
||||
this.matchesUpdated.addAll(conn.getMatches(String.valueOf(season), String.valueOf(league)));
|
||||
|
||||
missingTeams = new ArrayList<>();
|
||||
|
||||
teamsOriginal = conn.getTeams(String.valueOf(season), String.valueOf(league));
|
||||
|
||||
HashSet<Integer> missingIds = this.initMissingIds();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.tippliga.TLWMatch;
|
||||
import de.jeyp91.tippliga.TLWTeam;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import java.util.ArrayList;
|
||||
@@ -15,11 +18,14 @@ public class TippligaSQLConnector {
|
||||
|
||||
Connection con;
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(TippligaSQLConnector.class);
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
System.err.println("Unable to load MySQL Driver");
|
||||
logger.error("Unable to load MySQL Driver");
|
||||
StatusHolder.setError();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +120,7 @@ public class TippligaSQLConnector {
|
||||
executeQuery(queryString);
|
||||
}
|
||||
|
||||
private ResultSet executeQuery (String queryString){
|
||||
public ResultSet executeQuery (String queryString){
|
||||
Statement stmt;
|
||||
ResultSet rset = null;
|
||||
try {
|
||||
|
||||
2
src/test/java/de/jeyp91/gists/GistProviderTest.java
Normal file
2
src/test/java/de/jeyp91/gists/GistProviderTest.java
Normal file
@@ -0,0 +1,2 @@
|
||||
package de.jeyp91.gists;public class GistProviderTest {
|
||||
}
|
||||
@@ -6,21 +6,15 @@ public class TLWTeamsUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void getInsertSQLTest1() throws Exception {
|
||||
TLWMatchesUpdaterFootball matchesUpdater = new TLWMatchesUpdaterFootball(2021, 1, "Tippliga.json");
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 1, matchesUpdater.tlwMatchesUpdated);
|
||||
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 1, "Tippliga.json");
|
||||
String sql = teamsUpdater.getInsertSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInsertSQLTest2() throws Exception {
|
||||
TLWMatchesUpdaterFootball matchesUpdater = new TLWMatchesUpdaterFootball(2021, 2, "Tippliga.json");
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 2, matchesUpdater.tlwMatchesUpdated);
|
||||
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 2, "Tippliga.json");
|
||||
String sql = teamsUpdater.getInsertSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user