From 087101b076989e0e7b94bb9d29e2d8fb3a34874e Mon Sep 17 00:00:00 2001 From: wsbrenk Date: Sat, 8 Jul 2023 23:49:46 +0200 Subject: [PATCH] #1889 download new trainer info from player details --- build.gradle | 10 ++--- .../java/core/file/xml/ConvertXml2Hrf.java | 18 ++++++-- .../java/core/file/xml/XMLPlayersParser.java | 7 +++ src/main/java/core/model/player/Player.java | 12 +++-- src/main/java/core/net/MyConnector.java | 2 +- .../training/ui/model/TrainingModel.java | 8 ++-- src/main/resources/changelog.md | 44 ++++++++++++++++++- src/main/resources/release_notes.md | 20 +++------ 8 files changed, 89 insertions(+), 32 deletions(-) diff --git a/build.gradle b/build.gradle index 33845cdbb..cf6cb2dfd 100644 --- a/build.gradle +++ b/build.gradle @@ -39,8 +39,8 @@ test { // Version ============================================================ // Development_stage (DEV:0 BETA:1 STABLE:2) def major = '7' -def minor = '1' -def development_stage = 2 +def minor = '2' +def development_stage = 1 def releaseArtefacts = true def development_tag = ["dev", "beta", "tag_stable"] def version_type = ["-DEV", "-BETA", ""] @@ -309,9 +309,9 @@ task pushmd(dependsOn: preparingBuild) { // list the contributors that don't want to be mentioned in release notes def contributorFilter = ["Che"] - def commitCount = callGit('git rev-list 7.0..HEAD --count') - def diff = callGit('git diff --shortstat 7.0..HEAD') - def contributors = filter(callGit('git shortlog -s -n 7.0..HEAD'), contributorFilter) + def commitCount = callGit('git rev-list 7.1..HEAD --count') + def diff = callGit('git diff --shortstat 7.1..HEAD') + def contributors = filter(callGit('git shortlog -s -n 7.1..HEAD'), contributorFilter) def latestCommit = callGit('git log -1 --pretty=format:"%s"') println("create release-notes") diff --git a/src/main/java/core/file/xml/ConvertXml2Hrf.java b/src/main/java/core/file/xml/ConvertXml2Hrf.java index 19d6b3020..6a4c2aa8a 100644 --- a/src/main/java/core/file/xml/ConvertXml2Hrf.java +++ b/src/main/java/core/file/xml/ConvertXml2Hrf.java @@ -22,8 +22,7 @@ import java.util.List; import java.util.Map; -import static core.net.OnlineWorker.downloadLastLineup; -import static core.net.OnlineWorker.downloadNextMatchOrder; +import static core.net.OnlineWorker.*; /** * Convert the necessary xml data into a HRF file. @@ -127,6 +126,20 @@ private ConvertXml2Hrf() { HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.players_information"), progressIncrement); List playersData = new XMLPlayersParser().parsePlayersFromString(mc.downloadPlayers(teamId)); + var trainerId = String.valueOf(teamdetailsDataMap.get("TrainerID")); + // If trainer is not in players data, download trainer info from player details + var found = false; + for ( var p : playersData){ + if ( p.get("PlayerID").equals(trainerId)){ + found=true; + break; + } + } + if ( !found){ + var xml = MyConnector.instance().downloadPlayerDetails(trainerId); + playersData.add(new XMLPlayersParser().parsePlayerDetails(xml)); + } + // Download players' avatar HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.players_avatars"), progressIncrement); @@ -187,7 +200,6 @@ private ConvertXml2Hrf() { hrfSgtringBuilder.createTeam(trainingDataMap); // lineup - var trainerId = String.valueOf(teamdetailsDataMap.get("TrainerID")); HOMainFrame.instance().setInformation(Helper.getTranslation("ls.update_status.create_lineups"), progressIncrement); hrfSgtringBuilder.createLineUp(trainerId, teamId, nextLineupDataMap); diff --git a/src/main/java/core/file/xml/XMLPlayersParser.java b/src/main/java/core/file/xml/XMLPlayersParser.java index bc3d02776..9809bbf1d 100644 --- a/src/main/java/core/file/xml/XMLPlayersParser.java +++ b/src/main/java/core/file/xml/XMLPlayersParser.java @@ -38,6 +38,13 @@ public final Vector parsePlayersFromString(String inputStream) { return createListe(doc); } + public final MyHashtable parsePlayerDetails(String inputStream){ + Document doc = XMLManager.parseString(inputStream); + Element root = doc.getDocumentElement(); + Element ele = (Element) root.getElementsByTagName("Player").item(0); + return createPlayerDetails(ele); + } + ///////////////////////////////////////////////////////////////////////////////// //Parser Helper private //////////////////////////////////////////////////////////////////////////////// diff --git a/src/main/java/core/model/player/Player.java b/src/main/java/core/model/player/Player.java index bd8d45c7e..3e1e7ed09 100644 --- a/src/main/java/core/model/player/Player.java +++ b/src/main/java/core/model/player/Player.java @@ -437,7 +437,13 @@ public Player(java.util.Properties properties, HODateTime hrfdate, int hrf_id) { m_iTransferlisted = Boolean.parseBoolean(properties.getProperty("transferlisted", "False")) ? 1 : 0; m_iLaenderspiele = Integer.parseInt(properties.getProperty("caps", "0")); m_iU20Laenderspiele = Integer.parseInt(properties.getProperty("capsu20", "0")); - nationalTeamId = Integer.parseInt(properties.getProperty("nationalteamid", "0")); + var ntTeamId = properties.getProperty("nationalteamid", "0"); + if ( ntTeamId.isEmpty()){ + nationalTeamId=0; + } + else { + nationalTeamId = Integer.parseInt(ntTeamId); + } // #461-lastmatch m_lastMatchDate = properties.getProperty("lastmatch_date"); @@ -489,8 +495,8 @@ private void downloadMotherclubInfoIfMissing() { var isSilentDownload = connection.isSilentDownload(); try { connection.setSilentDownload(true); - // try to download missing motherclub info - var playerDetails = OnlineWorker.downloadPlayerDetails(""+this.getPlayerID()); + // try to download missing mother club info + var playerDetails = OnlineWorker.downloadPlayerDetails(String.valueOf(this.getPlayerID())); if (playerDetails != null) { motherclubId = playerDetails.getMotherclubId(); motherclubName = playerDetails.getMotherclubName(); diff --git a/src/main/java/core/net/MyConnector.java b/src/main/java/core/net/MyConnector.java index 12c3d5aa1..6ab68a6d2 100644 --- a/src/main/java/core/net/MyConnector.java +++ b/src/main/java/core/net/MyConnector.java @@ -450,7 +450,7 @@ public String downloadYouthPlayers(int youthteamId) { */ public String getStaff(int teamId) { - String url = htUrl + "?file=stafflist&version=1.0&teamId=" + teamId; + String url = htUrl + "?file=stafflist&version=1.1&teamId=" + teamId; return getCHPPWebFile(url); } diff --git a/src/main/java/module/training/ui/model/TrainingModel.java b/src/main/java/module/training/ui/model/TrainingModel.java index 7326fbd58..5be0bcbbd 100644 --- a/src/main/java/module/training/ui/model/TrainingModel.java +++ b/src/main/java/module/training/ui/model/TrainingModel.java @@ -162,13 +162,13 @@ private boolean isOsmosisTrainingAvailable(TrainingPerWeek t) { } private List adjustFutureTrainingsVector(List _futureTrainings, int requiredNBentries) { - List newfutureTrainings = new ArrayList<>(); + List newFutureTrainings = new ArrayList<>(); TrainingPerWeek previousTraining = TrainingManager.instance().getNextWeekTraining(); HOLogger.instance().debug(TrainingModel.class, "Previous training date: " + previousTraining); if ( previousTraining != null) { TrainingPerWeek futureTraining; - while (newfutureTrainings.size() < requiredNBentries) { + while (newFutureTrainings.size() < requiredNBentries) { //first iteration equals to nextWeek training then increase per one week per iteration var futureTrainingDate = previousTraining.getTrainingDate().plusDaysAtSameLocalTime(7); var storedFutureTrainings = _futureTrainings.stream().filter(t -> futureTrainingDate.equals(t.getTrainingDate())).toList(); @@ -180,10 +180,10 @@ private List adjustFutureTrainingsVector(List futureTraining = new TrainingPerWeek(futureTrainingDate, previousTraining.getTrainingType(), previousTraining.getTrainingIntensity(), previousTraining.getStaminaShare(), previousTraining.getTrainingAssistantsLevel(), previousTraining.getCoachLevel(), DBDataSource.GUESS); } - newfutureTrainings.add(futureTraining); + newFutureTrainings.add(futureTraining); previousTraining = futureTraining; } } - return newfutureTrainings; + return newFutureTrainings; } } diff --git a/src/main/resources/changelog.md b/src/main/resources/changelog.md index d1855e08c..8bc1eb73d 100644 --- a/src/main/resources/changelog.md +++ b/src/main/resources/changelog.md @@ -1,3 +1,45 @@ +# Changelist HO! 7.1 + +## Some numbers +* 11 commits +* 34 files changed, 1085 insertions(+), 1213 deletions(-) +* Contributors: + * 9 wsbrenk + * 2 Sébastien Le Callonnec + +## Highlights +* bug fixes + +## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.1) + +### Squad +* fix click on “Last Match” column when the column has been moved. +* fix last match info of nt teams (#1878) + +### Matches +* fix missing player names in match highlights panel (#1857) + +### Lineup +* fix nt team selection options of style of play combo box (#1873) +* fix download error of substitutions with undocumented goal difference criteria (#1881) + +### Statistics +* fix currency of secondary teams (#1856) + +### Transfer +* fix bugs in transfer scout panel (#1858) + +## Translations + +Reports by Contributors - April 22, 2023 - June 24, 2023 + +* Achilles 272 +* sich 4 +* Lidegand 4 +* wsbrenk 4 + +Total 288 + # Changelist HO! 7.0 ## Some numbers @@ -98,7 +140,7 @@ Total 234 * 11 commits * 22 files changed, 469 insertions(+), 493 deletions(-) * Contributors: - 11 wsbrenk + * 11 wsbrenk ## Highlights * bug fixes diff --git a/src/main/resources/release_notes.md b/src/main/resources/release_notes.md index 6768f186c..c738cccf1 100644 --- a/src/main/resources/release_notes.md +++ b/src/main/resources/release_notes.md @@ -4,32 +4,26 @@ bug fixes -## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A8.0) +## [Detailed Changelog](https://github.com/akasolace/HO/issues?q=milestone%3A7.2) ### Database ### Squad -* fix click on “Last Match” column when the column has been moved. -* fix last match info of nt teams (#1878) ### Team Analyzer ### Rating ### Matches -* fix missing player names in match highlights panel (#1857) ### Lineup -* fix nt team selection options of style of play combo box (#1873) -* fix download error of substitutions with undocumented goal difference criteria (#1881) ### Statistics -* fix currency of secondary teams (#1856) ### Transfer -* fix bugs in transfer scout panel (#1858) ### Training +* handle new trainer types which are no longer listed as player (#1889) ### League @@ -39,11 +33,7 @@ bug fixes ## Translations -Reports by Contributors - April 22, 2023 - June 24, 2023 +Reports by Contributors - June 24, 2023 - July 08, 2023 +* Miccoli17 1 -* Achilles 272 -* sich 4 -* Lidegand 4 -* wsbrenk 4 - -Total 288 \ No newline at end of file +Total 1 \ No newline at end of file