-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #1962 refactoring PlayerSkill class->enum * #1962 refactoring PlayerSkill class->enum * #1962 refactoring PlayerSkill: remove PlayerSkillColumn.getSkill * #1962 refactoring PlayerSkill: remove HTSkillID * #1962 refactoring PlayerSkill: remove redundant Skills.getSkillValue * #1962 refactoring PlayerSkill.toString -> getLanguageString * #1962 refactoring remove PastSkillChange.java * hsqldb 2.7.2 * Refactor prepared statement caching logic. This commit introducts a `StatementCache` that manages the cached `PreparedStatement`s in a straightforward and consistent manner; the statements in this cache can easily be cleared out, and the cache can also be disabled. It also keeps tracks of statistics about the prepared statements that can be useful for debugging and tracking commonly used ones. This also removes some of the ad-hoc attempts at achieving similar caching (e.g. in `TrainingsTable`, `DBUpdater`, etc.). Finally, it also deletes the `XMLExporter` class, which has now become obsolete, per discussion: #1942 * #1886 (wip) * #1886 merge * #1886 PlayerDetailPanel loads correct skill training priority * #1886 fix FuturePlayerTraining.cut (create unit test) * #1886 fix FuturePlayerTraining.cut (create unit test) * #1886 delete TrainingPlanPanel.java * #1886 fix FuturePlayerTrainingTable.storeFuturePlayerTrainings --------- Co-authored-by: Sébastien Le Callonnec <[email protected]>
- Loading branch information
1 parent
0c1b3fb
commit 73214a3
Showing
19 changed files
with
469 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package core.db; | ||
|
||
|
||
import core.constants.player.PlayerSkill; | ||
import core.training.FuturePlayerSkillTraining; | ||
import core.training.FuturePlayerTraining; | ||
|
||
import java.sql.Types; | ||
import java.util.List; | ||
|
||
public class FuturePlayerSkillTrainingTable extends AbstractTable { | ||
|
||
public final static String TABLENAME = "FUTUREPLAYERSKILLTRAINING"; | ||
|
||
/** | ||
* constructor | ||
*/ | ||
public FuturePlayerSkillTrainingTable(ConnectionManager adapter) { | ||
super(TABLENAME, adapter); | ||
} | ||
|
||
@Override | ||
protected void initColumns() { | ||
columns = new ColumnDescriptor[]{ | ||
ColumnDescriptor.Builder.newInstance() | ||
.setColumnName("playerId") | ||
.setGetter((o) -> ((FuturePlayerSkillTraining) o).getPlayerId()) | ||
.setSetter((o, v) -> ((FuturePlayerSkillTraining) o).setPlayerId((int) v)) | ||
.setType(Types.INTEGER) | ||
.isNullable(false) | ||
.build(), | ||
ColumnDescriptor.Builder.newInstance() | ||
.setColumnName("skillId") | ||
.setGetter((o) -> ((FuturePlayerSkillTraining) o).getSkillId().toInt()) | ||
.setSetter((o, v) -> ((FuturePlayerSkillTraining) o).setSkillId(PlayerSkill.fromInteger((int) v))) | ||
.setType(Types.INTEGER) | ||
.isNullable(false) | ||
.build(), | ||
ColumnDescriptor.Builder.newInstance() | ||
.setColumnName("prio") | ||
.setGetter((o) -> FuturePlayerSkillTraining.getPriorityAsInteger((FuturePlayerSkillTraining)o)) | ||
.setSetter((o, v) -> ((FuturePlayerSkillTraining) o).setPriority(FuturePlayerTraining.Priority.valueOf((Integer) v))) | ||
.setType(Types.INTEGER) | ||
.isNullable(true) | ||
.build() | ||
}; | ||
} | ||
|
||
List<FuturePlayerSkillTraining> loadFuturePlayerSkillTraining(int playerId) { | ||
return load(FuturePlayerSkillTraining.class, playerId); | ||
} | ||
|
||
public void storeFuturePlayerSkillTraining(int playerId, List<FuturePlayerSkillTraining> futurePlayerTrainings) { | ||
executePreparedDelete(playerId); | ||
for (var t : futurePlayerTrainings) { | ||
store(t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/core/training/FuturePlayerSkillTraining.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package core.training; | ||
|
||
import core.constants.player.PlayerSkill; | ||
import core.db.AbstractTable; | ||
import core.training.FuturePlayerTraining.Priority; | ||
|
||
public class FuturePlayerSkillTraining extends AbstractTable.Storable { | ||
|
||
/** | ||
* Player Id | ||
*/ | ||
private int playerId; | ||
|
||
public static Integer getPriorityAsInteger(FuturePlayerSkillTraining o) { | ||
if (o != null && o.getPriority() != null) { | ||
return o.getPriority().getValue(); | ||
} | ||
return null; | ||
} | ||
|
||
public PlayerSkill getSkillId() { | ||
return skillId; | ||
} | ||
|
||
public void setSkillId(PlayerSkill skillId) { | ||
this.skillId = skillId; | ||
} | ||
|
||
private PlayerSkill skillId; | ||
|
||
/** | ||
* priority of the training | ||
*/ | ||
private Priority priority; | ||
|
||
public FuturePlayerSkillTraining(int playerId, Priority prio, PlayerSkill skill) { | ||
this.playerId = playerId; | ||
this.priority = prio; | ||
this.skillId = skill; | ||
} | ||
|
||
/** | ||
* constructor is used by AbstractTable.load | ||
*/ | ||
public FuturePlayerSkillTraining(){} | ||
|
||
public Priority getPriority() { | ||
return priority; | ||
} | ||
|
||
public void setPriority(Priority prio) { | ||
this.priority = prio; | ||
} | ||
|
||
public int getPlayerId() { | ||
return this.playerId; | ||
} | ||
|
||
public void setPlayerId(int playerId) { | ||
this.playerId = playerId; | ||
} | ||
|
||
} |
Oops, something went wrong.