package com.dungeonstory.backend.data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotNull;

@Entity
@IdClass(ClassSpecLevelFeatureId.class)
@Table(name = "ClassSpecLevelFeature")
public class ClassSpecLevelFeature {
    
    @Id
    @ManyToOne
    @JoinColumn(name = "classSpecId", nullable = false)
    private ClassSpecialization classSpec;

    @Id
    @NotNull
    @ManyToOne
    @JoinColumn(name = "levelId", nullable = false)
    private Level level;

    @Id
    @NotNull
    @ManyToOne
    @JoinColumn(name = "featureId", nullable = false)
    private ClassFeature feature;
    
    @Digits(integer = 1, fraction = 0)
    @Column(name = "nbToChoose")
    private int nbToChoose = 1;

    public ClassSpecLevelFeature() {
        super();
    }

    public ClassSpecialization getClassSpec() {
        return classSpec;
    }

    public void setClassSpec(ClassSpecialization classSpec) {
        this.classSpec = classSpec;
    }

    public Level getLevel() {
        return level;
    }

    public void setLevel(Level level) {
        this.level = level;
    }

    public ClassFeature getFeature() {
        return feature;
    }

    public void setFeature(ClassFeature feature) {
        this.feature = feature;
    }

    public int getNbToChoose() {
        return nbToChoose;
    }

    public void setNbToChoose(int nbToChoose) {
        this.nbToChoose = nbToChoose;
    }

    @Override
    public String toString() {
        return feature.getName() + " (niv. " + level.getId() + ")";
    }
        
}

@@ -369,16 +369,136 @@
 ull;%0D%0A%0D%0A
+import org.eclipse.persistence.annotations.Customizer;%0D%0A%0D%0Aimport com.dungeonstory.backend.data.util.OrderCustomizer;%0D%0A%0D%0A
 @Entity%0D
@@ -579,16 +579,52 @@
 ture%22)%0D%0A
+@Customizer(OrderCustomizer.class)%0D%0A
 public c
@@ -664,24 +664,38 @@
  %0D%0A    @Id%0D%0A
+    @NotNull%0D%0A
     @ManyToO
@@ -722,25 +722,21 @@
 name = %22
-classSpec
+level
 Id%22, nul
@@ -767,37 +767,19 @@
 ate 
-ClassSpecialization classSpec
+Level level
 ;%0D%0A%0D
@@ -784,38 +784,24 @@
 %0A%0D%0A    @Id%0D%0A
-    @NotNull%0D%0A
     @ManyToO
@@ -820,37 +820,41 @@
 nColumn(name = %22
-level
+classSpec
 Id%22, nullable = 
@@ -869,35 +869,53 @@
     private 
-Level level
+ClassSpecialization classSpec
 ;%0D%0A%0D%0A    @Id
@@ -1128,19 +1128,23 @@
 private 
-i
+I
 nt
+eger
  nbToCho
@@ -1149,17 +1149,20 @@
 hoose = 
-1
+null
 ;%0D%0A%0D%0A   
@@ -1738,19 +1738,23 @@
  public 
-i
+I
 nt
+eger
  getNbTo
@@ -1832,19 +1832,23 @@
 oChoose(
-i
+I
 nt
+eger
  nbToCho

fix ClassSpecLevelFeature column order