Remove Gist

This commit is contained in:
2020-11-08 23:04:32 +01:00
parent 633b633e2b
commit 4119163c4c
48 changed files with 2792 additions and 668 deletions
@@ -4,10 +4,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import de.jeyp91.BaseMatch;
import de.jeyp91.StatusHolder;
import de.jeyp91.TeamIDMatcher;
import de.jeyp91.teamidmatcher.TeamIDMatcher;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.openligadb.OpenLigaDBMatch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -1,13 +1,9 @@
package de.jeyp91.tippliga;
import de.jeyp91.gists.GistProvider;
import de.jeyp91.tippligaforum.TippligaConfigProvider;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -27,15 +23,9 @@ public class TLWMatchdaysCreator {
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
this.matches = matchesCreator.getMatches();
GistProvider prov = GistProvider.getInstance();
String jsonConfig = prov.getTippligaConfig(configPath);
TippligaConfigProvider prov = new TippligaConfigProvider(season);
this.configObject = prov.getTippligaConfig(configPath);
JSONParser jsonParser = new JSONParser();
try {
this.configObject = (JSONObject) jsonParser.parse(jsonConfig);
} catch (ParseException e) {
e.printStackTrace();
}
//Read JSON file
this.matchesPerMatchday = ((Long) this.configObject.get("matchesPerMatchday")).intValue();
}
@@ -1,6 +1,7 @@
package de.jeyp91.tippliga;
import java.text.ParseException;
import de.jeyp91.tippligaforum.TippligaSQLConnector;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
@@ -14,11 +15,11 @@ public class TLWMatchdaysUpdater {
ArrayList<TLWMatchday> matchdaysUpdated;
String beautifulInfo = "";
public TLWMatchdaysUpdater(int season, int league, String configPath) throws ParseException {
public TLWMatchdaysUpdater(int season, int league, String configPath) {
this.season = season;
this.league = league;
TippligaSQLConnector conn = new TippligaSQLConnector();
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
this.matchdaysOriginal = conn.getMatchdays(String.valueOf(season), String.valueOf(league));
this.matchdaysOriginal.sort(Comparator.comparing(TLWMatchday::getMatchday));
@@ -1,21 +1,13 @@
package de.jeyp91.tippliga;
import com.google.common.io.Resources;
import de.jeyp91.apifootball.APIFootballConnector;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.gists.GistProvider;
import de.jeyp91.tippligaforum.TippligaConfigProvider;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
@@ -35,20 +27,12 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
this.league = league;
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
GistProvider prov = GistProvider.getInstance();
String jsonConfig = prov.getTippligaConfig(configFileName);
TippligaConfigProvider prov = new TippligaConfigProvider(season);
JSONObject config = prov.getTippligaConfig(configFileName);
try {
JSONParser jsonParser = new JSONParser();
//Read JSON file
JSONObject config = (JSONObject) jsonParser.parse(jsonConfig);
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
this.ko = ((Long) config.get("ko")).intValue();
} catch (ParseException e) {
e.printStackTrace();
}
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
this.ko = ((Long) config.get("ko")).intValue();
this.publicateMatchObjects();
}
@@ -1,13 +1,12 @@
package de.jeyp91.tippliga;
import de.jeyp91.ResourceProvider;
import de.jeyp91.StatusHolder;
import de.jeyp91.gists.GistProvider;
import de.jeyp91.tippligaforum.TippligaConfigProvider;
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;
import org.json.simple.parser.ParseException;
import java.util.ArrayList;
@@ -28,22 +27,12 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
this.league = league;
this.matchdays = matchdays;
try {
JSONParser jsonParser = new JSONParser();
GistProvider prov = GistProvider.getInstance();
String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json");
this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString);
this.matchPairingConfig = ResourceProvider.getTipperMatchPairConfig();
this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig();
String tipperListString = prov.getTippligaConfig(configFileName);
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString);
} catch (ParseException e) {
e.printStackTrace();
}
TippligaConfigProvider prov = new TippligaConfigProvider(season);
this.tipperList = prov.getTippligaConfig(configFileName);
this.publicateMatchObjects();
}
@@ -1,12 +1,11 @@
package de.jeyp91.tippliga;
import de.jeyp91.gists.GistProvider;
import de.jeyp91.ResourceProvider;
import de.jeyp91.tippligaforum.TippligaConfigProvider;
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;
import org.json.simple.parser.ParseException;
import java.util.ArrayList;
@@ -27,24 +26,13 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
this.league = league;
this.matchdays = matchdays;
TippligaConfigProvider prov = new TippligaConfigProvider(season);
this.tipperList = prov.getTippligaConfig(configFileName);
GistProvider prov = GistProvider.getInstance();
this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig();
this.TLWMatches = new ArrayList<>();
try {
JSONParser jsonParser = new JSONParser();
String tipperListString = prov.getTippligaConfig(configFileName);
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString);
} catch (ParseException e) {
e.printStackTrace();
}
this.publicateMatchObjects();
}
@@ -1,19 +1,14 @@
package de.jeyp91.tippliga;
import com.google.api.client.util.DateTime;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.gists.GistProvider;
import de.jeyp91.tippligaforum.TippligaConfigProvider;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
public class TLWMatchesManagerBase {
@@ -27,19 +22,11 @@ public class TLWMatchesManagerBase {
protected void initConfigParamsFromFile(String configFileName) {
GistProvider prov = GistProvider.getInstance();
String jsonConfig = prov.getTippligaConfig(configFileName);
try {
JSONParser jsonParser = new JSONParser();
//Read JSON file
JSONObject config = (JSONObject) jsonParser.parse(jsonConfig);
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
this.ko = ((Long) config.get("ko")).intValue();
} catch (ParseException e) {
e.printStackTrace();
}
TippligaConfigProvider prov = new TippligaConfigProvider(this.season);
JSONObject config = prov.getTippligaConfig(configFileName);
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
this.ko = ((Long) config.get("ko")).intValue();
}
public static ArrayList<TLWMatch> getMatchesStartingFromSecondDay(ArrayList<TLWMatch> matches) {
@@ -2,9 +2,10 @@ package de.jeyp91.tippliga;
import de.jeyp91.App;
import de.jeyp91.StatusHolder;
import de.jeyp91.TeamIDMatcher;
import de.jeyp91.teamidmatcher.TeamIDMatcher;
import de.jeyp91.apifootball.APIFootballMatch;
import de.jeyp91.apifootball.APIFootballMatchesProvider;
import de.jeyp91.tippligaforum.TippligaSQLConnector;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.simple.JSONArray;
@@ -35,7 +36,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
private void initUpdates() {
APIFootballMatchesProvider apiFootballMatchesProvider = new APIFootballMatchesProvider(this.season);
TippligaSQLConnector tippligaSQLConnector = new TippligaSQLConnector();
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
for (Object singleMatchdayConfig : this.matchdayConfig) {
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
@@ -1,5 +1,7 @@
package de.jeyp91.tippliga;
import de.jeyp91.tippligaforum.TippligaSQLConnector;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -8,7 +10,7 @@ public class TLWTeamsCreator {
int season;
int league;
ArrayList<TLWMatch> matches;
TippligaSQLConnector connector = new TippligaSQLConnector();
TippligaSQLConnector connector = TippligaSQLConnector.getInstance();
public TLWTeamsCreator(int season, int league, ArrayList<TLWMatch> matches) {
this.season = season;
@@ -1,5 +1,7 @@
package de.jeyp91.tippliga;
import de.jeyp91.tippligaforum.TippligaSQLConnector;
import java.util.ArrayList;
import java.util.HashSet;
@@ -13,7 +15,7 @@ public class TLWTeamsUpdater {
public TLWTeamsUpdater(int season, int league, String configFileName) throws Exception {
TippligaSQLConnector conn = new TippligaSQLConnector();
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
this.season = season;
this.league = league;
@@ -47,7 +49,7 @@ public class TLWTeamsUpdater {
}
private void initMissingTeams(HashSet<Integer> missingIds) {
TippligaSQLConnector conn = new TippligaSQLConnector();
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
for (Integer id : missingIds) {
ArrayList<TLWTeam> teams = conn.getTeams(String.valueOf(id));
missingTeams.add(new TLWTeam(
@@ -1,158 +0,0 @@
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;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
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) {
logger.error("Unable to load MySQL Driver");
StatusHolder.setError();
}
}
public TippligaSQLConnector() {
String jdbcUrlLocalhost = "jdbc:mysql://localhost/d0144ddb" +
"?user=root" +
"&password=" +
"&useUnicode=true" +
"&useJDBCCompliantTimezoneShift=true" +
"&useLegacyDatetimeCode=false" +
"&serverTimezone=UTC" +
"&allowMultiQueries=true";
String jdbcUrlProd = "jdbc:mysql://dd16124.kasserver.com/d0144ddb" +
"?user=d0144ddb" +
"&password=TippligaWuerzb_1" +
"&useUnicode=true" +
"&useJDBCCompliantTimezoneShift=true" +
"&useLegacyDatetimeCode=false" +
"&serverTimezone=UTC" +
"&allowMultiQueries=true";
try {
con = DriverManager.getConnection(jdbcUrlProd);
} catch (SQLException e) {
/* TODO */
e.printStackTrace();
}
}
public ArrayList<TLWTeam> getTeams(String season, String league) {
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `season` = " + season + " AND `league` = " + league + ";";
ArrayList<TLWTeam> teams = new ArrayList<>();
ResultSet rset = executeQuery(queryString);
try {
while (rset.next()) {
teams.add(new TLWTeam(rset));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return teams;
}
public ArrayList<TLWTeam> getTeams(String id) {
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + " ORDER BY `season` DESC, `league` ASC;";
ArrayList<TLWTeam> teams = new ArrayList<>();
ResultSet rset = executeQuery(queryString);
try {
while (rset.next()) {
teams.add(new TLWTeam(rset));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return teams;
}
private ArrayList<TLWMatch> getMatches(String queryString) {
ArrayList<TLWMatch> matches = new ArrayList<>();
ResultSet rset = executeQuery(queryString);
try {
while (rset.next()) {
matches.add(new TLWMatch(rset));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return matches;
}
public ArrayList<TLWMatch> getMatches(String season, String league) {
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + " ORDER BY match_no ASC;";
return getMatches(queryString);
}
public ArrayList<TLWMatch> getMatches(String season, String league, String matchday) {
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + " AND `matchday` = " + matchday + " ORDER BY match_no ASC;";
return getMatches(queryString);
}
public ArrayList<TLWMatchday> getMatchdays(String season, String league) {
String queryString = "SELECT * FROM `phpbb_footb_matchdays` WHERE `season` = " + season + " AND `league` = " + league + ";";
ArrayList<TLWMatchday> matchdays = new ArrayList<>();
ResultSet rset = executeQuery(queryString);
try {
while (rset.next()) {
matchdays.add(new TLWMatchday(rset));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return matchdays;
}
public void updateMatchDateTime(String season, String league, String matchNo, String datetime) {
String queryString = "UPDATE `phpbb_footb_matches` "
+ "SET match_datetime = " + datetime
+ " WHERE `season` = " + season
+ " AND `league` = " + league
+ " AND match_no = " + matchNo + ";";
executeQuery(queryString);
}
public ResultSet executeQuery (String queryString){
Statement stmt;
ResultSet rset = null;
try {
stmt = con.createStatement();
rset = stmt.executeQuery(queryString);
} catch (SQLException e) {
logger.error(e.getStackTrace());
}
return rset;
}
public void executeUpdate (String queryString){
Statement stmt;
try {
stmt = con.createStatement();
stmt.executeUpdate(queryString);
} catch (SQLException e) {
logger.error(e.getMessage());
}
}
}