merge dev
This commit is contained in:
commit
6ae5799eac
8 changed files with 105 additions and 73 deletions
|
|
@ -65,16 +65,4 @@ public class PreferenceController {
|
|||
PreferencePK id = new PreferencePK(personneRepository.getById(iduser) ,restaurantRepository.getById(idrestau));
|
||||
preferenceRepository.deleteById(id);
|
||||
}
|
||||
|
||||
// @DeleteMapping("/delete-pref-byrestau/{idrestau}")
|
||||
// public void deletePreferenceByRestau(@PathVariable int idrestau ){
|
||||
// List<Personne> list = personneRepository.findAll();
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// if(findPreferenceById(list.get(i).getId(),idrestau).isEmpty() == false) {
|
||||
// preferenceRepository.deleteById(new PreferencePK(list.get(i),new Restaurant(idrestau)));
|
||||
// }
|
||||
// //System.out.println(findPreferenceById(list.get(i).getId(),idrestau).isEmpty());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,16 +116,19 @@ public class Personne {
|
|||
public void setRoles(Collection<Role> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
@OneToMany(mappedBy = "personne", cascade = CascadeType.REMOVE)
|
||||
@OneToMany(mappedBy = "preferencePK.personne", cascade = CascadeType.REMOVE)
|
||||
@JsonIgnore
|
||||
public Collection<Preference> getPreference() {
|
||||
return preference;
|
||||
}
|
||||
|
||||
|
||||
public void setPreference(Collection<Preference> preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ package fr.cardon.simpleat.model;
|
|||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
|
||||
|
||||
|
|
@ -30,6 +36,9 @@ public class PreferencePK implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
@ManyToOne
|
||||
@PrimaryKeyJoinColumn(name="id_personne", referencedColumnName ="id_personne" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Personne getPersonne() {
|
||||
return personne;
|
||||
}
|
||||
|
|
@ -39,6 +48,9 @@ public class PreferencePK implements Serializable {
|
|||
this.personne = personne;
|
||||
}
|
||||
|
||||
@ManyToOne // TODO mappedBy preferences dans restaurant
|
||||
@PrimaryKeyJoinColumn(name="id_restau",referencedColumnName ="id_restau" )
|
||||
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
|
||||
public Restaurant getRestau() {
|
||||
return restau;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,36 +24,22 @@ public class Restaurant {
|
|||
private String nom;
|
||||
private String adresse;
|
||||
private String telephone;
|
||||
private boolean aEmporter;
|
||||
private boolean surPlace;
|
||||
private int prix;
|
||||
private boolean accesPMR;
|
||||
private Boolean aEmporter;
|
||||
private Boolean surPlace;
|
||||
private Integer prix;
|
||||
private Boolean accesPMR;
|
||||
private String latitude;
|
||||
private String longitude;
|
||||
private String website;
|
||||
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
|
||||
private Collection<Preference> preference = new ArrayList<Preference>();
|
||||
|
||||
//TODO @OneToMany relier avec une collec de preferences
|
||||
|
||||
public Restaurant() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Restaurant(int id) {
|
||||
super();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, int prix,
|
||||
boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
|
||||
public Restaurant(String nom, String adresse, String telephone, Boolean aEmporter, Boolean surPlace, int prix,
|
||||
Boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
|
||||
super();
|
||||
this.nom = nom;
|
||||
this.adresse = adresse;
|
||||
|
|
@ -101,31 +87,31 @@ public class Restaurant {
|
|||
this.telephone = telephone;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isaEmporter() {
|
||||
public Boolean isaEmporter() {
|
||||
return aEmporter;
|
||||
}
|
||||
public void setaEmporter(boolean aEmporter) {
|
||||
public void setaEmporter(Boolean aEmporter) {
|
||||
this.aEmporter = aEmporter;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isSurPlace() {
|
||||
public Boolean isSurPlace() {
|
||||
return surPlace;
|
||||
}
|
||||
public void setSurPlace(boolean surPlace) {
|
||||
public void setSurPlace(Boolean surPlace) {
|
||||
this.surPlace = surPlace;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public int getPrix() {
|
||||
public Integer getPrix() {
|
||||
return prix;
|
||||
}
|
||||
public void setPrix(int prix) {
|
||||
public void setPrix(Integer prix) {
|
||||
this.prix = prix;
|
||||
}
|
||||
@Column(nullable = true)
|
||||
public boolean isAccesPMR() {
|
||||
public Boolean isAccesPMR() {
|
||||
return accesPMR;
|
||||
}
|
||||
public void setAccesPMR(boolean accesPMR) {
|
||||
public void setAccesPMR(Boolean accesPMR) {
|
||||
this.accesPMR = accesPMR;
|
||||
}
|
||||
@Column(nullable = false)
|
||||
|
|
@ -154,7 +140,6 @@ public class Restaurant {
|
|||
@JoinTable(name="type_restau",
|
||||
joinColumns = @JoinColumn(name = "id_restau"/*classe en cours*/,referencedColumnName = "id_restau" /*classe reliée*/) ,
|
||||
inverseJoinColumns = @JoinColumn(name = "id_type",referencedColumnName = "id_type"))
|
||||
@JsonIgnore
|
||||
public Collection<TypeRestau> getTyperestaus() {
|
||||
return typerestaus;
|
||||
}
|
||||
|
|
@ -162,8 +147,8 @@ public class Restaurant {
|
|||
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
|
||||
this.typerestaus = typerestaus;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy = "restau", cascade = CascadeType.REMOVE)
|
||||
|
||||
@OneToMany(mappedBy = "preferencePK.restau", cascade = CascadeType.REMOVE)
|
||||
@JsonIgnore
|
||||
public Collection<Preference> getPreference() {
|
||||
return preference;
|
||||
|
|
@ -173,7 +158,4 @@ public class Restaurant {
|
|||
public void setPreference(Collection<Preference> preference) {
|
||||
this.preference = preference;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,7 @@ import javax.persistence.Id;
|
|||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonBackReference;
|
||||
|
||||
|
||||
@Entity
|
||||
|
|
@ -50,7 +49,7 @@ public class TypeRestau {
|
|||
}
|
||||
|
||||
@ManyToMany(mappedBy="typerestaus")
|
||||
@JsonIgnoreProperties("typerestaus")
|
||||
@JsonBackReference("restaurants")
|
||||
public List<Restaurant> getRestaurants() {
|
||||
return restaurants;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue