Add support for parameters to start and update gradle to compile full jar
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
/*
|
||||
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));
|
||||
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 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));
|
||||
}
|
||||
private static void initOptions(String[] args) {
|
||||
ArgumentParser parser = ArgumentParsers.newFor("tlw").build()
|
||||
.defaultHelp(true)
|
||||
.description("");
|
||||
|
||||
// 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("-m", "--mode")
|
||||
.dest("mode")
|
||||
.choices("MatchdaysUpdater", "MatchesCreatorFootball", "MatchesUpdaterFootball", "TeamsUpdater")
|
||||
.help("")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
for (Match match : matchesTLW) {
|
||||
match.updateDataFromOpenLigaDb(matchDBJson);
|
||||
parser.addArgument("-s", "--season")
|
||||
.dest("season")
|
||||
.required(true)
|
||||
.type(Integer.class);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user