first commit

This commit is contained in:
Thomas Cardon 2022-01-19 15:16:16 +01:00
commit ec0dc019d8
29 changed files with 1458 additions and 0 deletions

View file

@ -0,0 +1,110 @@
package fr.cardon.simpleat.model;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
public class Personne {
private int id;
private String nom;
private String prenom;
private String email;
private String password;
private Collection<Role> roles = new ArrayList<Role>();
public Personne() {
super();
// TODO Auto-generated constructor stub
}
public Personne(String nom, String prenom, String email, String password) {
super();
this.nom = nom;
this.prenom = prenom;
this.email = email;
this.password = password;
}
public Personne(String nom, String prenom, String email, String password, Collection<Role> roles) {
super();
this.nom = nom;
this.prenom = prenom;
this.email = email;
this.password = password;
this.roles = roles;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_personne")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(nullable = false)
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
@Column(nullable = false)
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
@Column(nullable = false)
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(nullable = false)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@ManyToMany
@JoinTable(name="role_personne",
joinColumns = @JoinColumn(name = "id_perso"/*nom créé dans table asso*/,referencedColumnName = "id_personne" /*classe en cours*/) )
@JsonIgnoreProperties("roles")
public Collection<Role> getRoles() {
return roles;
}
public void setRoles(Collection<Role> roles) {
this.roles = roles;
}
}

View file

@ -0,0 +1,54 @@
package fr.cardon.simpleat.model;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@Entity
public class Preference {
private PreferencePK preferencePK;
private int note;
private boolean favoris;
public Preference() {
super();
// TODO Auto-generated constructor stub
}
public Preference(PreferencePK preferencePK, int note, boolean favoris) {
super();
this.preferencePK = preferencePK;
this.note = note;
this.favoris = favoris;
}
@EmbeddedId
public PreferencePK getPreferencePK() {
return preferencePK;
}
public void setPreferencePK(PreferencePK preferencePK) {
this.preferencePK = preferencePK;
}
@Column(nullable = true)
public int getNote() {
return note;
}
public void setNote(int note) {
this.note = note;
}
@Column(nullable = true)
public boolean isFavori() {
return favoris;
}
public void setFavori(boolean favoris) {
this.favoris = favoris;
}
}

View file

@ -0,0 +1,66 @@
package fr.cardon.simpleat.model;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Embeddable
public class PreferencePK implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Personne personne;
private Restaurant restau;
public PreferencePK() {
super();
// TODO Auto-generated constructor stub
}
public PreferencePK(Personne personne, Restaurant restau) {
super();
this.personne = personne;
this.restau = restau;
}
@ManyToOne
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public Personne getPersonne() {
return personne;
}
public void setPersonne(Personne personne) {
this.personne = personne;
}
@ManyToOne // TODO mappedBy preferences dans restaurant
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public Restaurant getRestau() {
return restau;
}
public void setRestau(Restaurant restau) {
this.restau = restau;
}
}

View file

@ -0,0 +1,40 @@
package fr.cardon.simpleat.model;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@Entity
public class Reservation {
private ReservationPK reservationpk;
private int nbPersonne;
public Reservation() {
super();
// TODO Auto-generated constructor stub
}
public Reservation(ReservationPK reservationpk, int nbPersonne) {
super();
this.reservationpk = reservationpk;
this.nbPersonne = nbPersonne;
}
@EmbeddedId
public ReservationPK getReservationpk() {
return reservationpk;
}
public void setReservationpk(ReservationPK reservationpk) {
this.reservationpk = reservationpk;
}
@Column(nullable = false)
public int getNbPersonne() {
return nbPersonne;
}
public void setNbPersonne(int nbPersonne) {
this.nbPersonne = nbPersonne;
}
}

View file

@ -0,0 +1,61 @@
package fr.cardon.simpleat.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Embeddable
public class ReservationPK implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Personne personne;
private Restaurant restau;
private Date date;
public ReservationPK() {
super();
// TODO Auto-generated constructor stub
}
public ReservationPK(Personne personne, Restaurant restau, Date date) {
super();
this.personne = personne;
this.restau = restau;
this.date = date;
}
@ManyToOne
@JoinColumn(name="id_personne", referencedColumnName ="id_personne" )
public Personne getPersonne() {
return personne;
}
public void setPersonne(Personne personne) {
this.personne = personne;
}
@ManyToOne
@JoinColumn(name="id_restau",referencedColumnName ="id_restau" )
public Restaurant getRestau() {
return restau;
}
public void setRestau(Restaurant restau) {
this.restau = restau;
}
@Column(name="date_resa")
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
}

View file

@ -0,0 +1,154 @@
package fr.cardon.simpleat.model;
import java.util.ArrayList;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
public class Restaurant {
private int id;
private String nom;
private String adresse;
private String telephone;
private boolean aEmporter;
private boolean surPlace;
private double prix;
private boolean accesPMR;
private String latitude;
private String longitude;
private String website;
private Collection<TypeRestau> typerestaus = new ArrayList<TypeRestau>();
//TODO @OneToMany relier avec une collec de preferences
public Restaurant() {
super();
// TODO Auto-generated constructor stub
}
public Restaurant(String nom, String adresse, String telephone, boolean aEmporter, boolean surPlace, double prix,
boolean accesPMR, String latitude, String longitude, String website, Collection<TypeRestau> typerestaus) {
super();
this.nom = nom;
this.adresse = adresse;
this.telephone = telephone;
this.aEmporter = aEmporter;
this.surPlace = surPlace;
this.prix = prix;
this.accesPMR = accesPMR;
this.latitude = latitude;
this.longitude = longitude;
this.website = website;
this.typerestaus = typerestaus;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_restau")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(nullable = false)
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
@Column(nullable = false)
public String getAdresse() {
return adresse;
}
public void setAdresse(String adresse) {
this.adresse = adresse;
}
@Column(nullable = true)
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
@Column(nullable = true)
public boolean isaEmporter() {
return aEmporter;
}
public void setaEmporter(boolean aEmporter) {
this.aEmporter = aEmporter;
}
@Column(nullable = true)
public boolean isSurPlace() {
return surPlace;
}
public void setSurPlace(boolean surPlace) {
this.surPlace = surPlace;
}
@Column(nullable = true)
public double getPrix() {
return prix;
}
public void setPrix(double prixMin) {
this.prix = prixMin;
}
@Column(nullable = true)
public boolean isAccesPMR() {
return accesPMR;
}
public void setAccesPMR(boolean accesPMR) {
this.accesPMR = accesPMR;
}
@Column(nullable = false)
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
@Column(nullable = false)
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
@Column(nullable = true)
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
@ManyToMany
@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"))
@JsonIgnoreProperties("typerestaus")
public Collection<TypeRestau> getTyperestaus() {
return typerestaus;
}
public void setTyperestaus(Collection<TypeRestau> typerestaus) {
this.typerestaus = typerestaus;
}
}

View file

@ -0,0 +1,41 @@
package fr.cardon.simpleat.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Role {
private int id;
private String intitule;
public Role() {
super();
// TODO Auto-generated constructor stub
}
public Role(int id, String intitule) {
super();
this.id = id;
this.intitule = intitule;
}
@Id
@Column(name = "id_role")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(nullable = false)
public String getIntitule() {
return intitule;
}
public void setIntitule(String intitule) {
this.intitule = intitule;
}
}

View file

@ -0,0 +1,61 @@
package fr.cardon.simpleat.model;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
@Table(name="type")
public class TypeRestau {
private int id;
private String libelle;
private List<Restaurant> restaurants;
public TypeRestau() {
super();
}
public TypeRestau(int id, String libelle) {
super();
this.id = id;
this.libelle = libelle;
}
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id_type")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Column(nullable = false)
public String getLibelle() {
return libelle;
}
public void setLibelle(String libelle) {
this.libelle = libelle;
}
@ManyToMany(mappedBy="typerestaus")
@JsonIgnoreProperties("typerestaus")
public List<Restaurant> getRestaurants() {
return restaurants;
}
public void setRestaurants(List<Restaurant> restaurants) {
this.restaurants = restaurants;
}
}