1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
| @Entity
public class Exercise extends MyTreeNode {
protected PropertyChangeSupport changeSupport;
private static final long serialVersionUID = 1L;
private String name;
private int actifPlayers;
private String materials;
private int exerciseTime;
private List<Evolution> evolutionList;
private List<Training> trainingList;
public Exercise() {
this.changeSupport = new PropertyChangeSupport(this);
this.father = null;
this.childList = new ArrayList<>();
this.name = "Exercise";
this.actifPlayers = 0;
this.materials = "";
this.exerciseTime = 0;
this.evolutionList = new ArrayList<>();
this.trainingList = new ArrayList<>();
}
public Exercise(String name, int actifPlayers, String materials, int exerciseTime, List<Evolution> evolutionList, List<Training> trainingList, MyTreeNode father) {
this.changeSupport = new PropertyChangeSupport(this);
this.name = name;
this.actifPlayers = actifPlayers;
this.materials = materials;
this.exerciseTime = exerciseTime;
this.evolutionList = evolutionList;
this.trainingList = trainingList;
this.father = father;
}
public int getActifPlayers() {
return actifPlayers;
}
public void setActifPlayers(int actifPlayers) {
int oldActifPlayers = this.actifPlayers;
this.actifPlayers = actifPlayers;
changeSupport.firePropertyChange("actifPlayers", oldActifPlayers, this.actifPlayers);
}
public void addEvolution(Evolution evolution){
evolutionList.add(evolution);
}
public void removeEvolution(Evolution evolution){
evolutionList.remove(evolution);
}
public void removeEvolution(int index){
evolutionList.remove(index);
}
@OneToMany(mappedBy = "exercise", cascade = {CascadeType.ALL})
public List<Evolution> getEvolutionList() {
return evolutionList;
}
public void setEvolutionList(List<Evolution> evolutionList) {
List<Evolution> oldEvolutionList = this.evolutionList;
this.evolutionList = evolutionList;
changeSupport.firePropertyChange("evolutionList", oldEvolutionList, this.evolutionList);
}
public int getExerciseTime() {
return exerciseTime;
}
public void setExerciseTime(int exerciseTime) {
int oldExerciseTime = this.exerciseTime;
this.exerciseTime = exerciseTime;
changeSupport.firePropertyChange("exerciseTime", oldExerciseTime, this.exerciseTime);
}
public String getMaterials() {
return materials;
}
public void setMaterials(String materials) {
String oldMaterials = this.materials;
this.materials = materials;
changeSupport.firePropertyChange("materials", oldMaterials, this.materials);
}
public String getName() {
return name;
}
public void setName(String name) {
String oldName = this.name;
this.name = name;
changeSupport.firePropertyChange("name", oldName, this.name);
}
@ManyToMany(mappedBy = "exerciseList", targetEntity = Training.class, cascade = {CascadeType.ALL})
@org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.ALL)
public List<Training> getTrainingList() {
return trainingList;
}
public void setTrainingList(List<Training> trainingList) {
this.trainingList = trainingList;
}
@Override
public String toString() {
return name;
}
@Override
public Enumeration<TreeNode> children() {
return null;
}
@Override
@Transient
public boolean getAllowsChildren() {
return false;
}
@Override
public TreeNode getChildAt(int childIndex) {
return childList.get(childIndex);
}
@Override
@Transient
public int getChildCount() {
return childList.size();
}
@Override
public int getIndex(TreeNode node) {
return childList.indexOf(node);
}
@Override
@Transient
public TreeNode getParent() {
return father;
}
@Override
@Transient
public boolean isLeaf() {
return true;
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
changeSupport.removePropertyChangeListener(listener);
}
} |
Partager